Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only apply key to keyed each block, not its children #1204

Merged
merged 2 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"nyc": "^11.1.0",
"prettier": "^1.7.0",
"reify": "^0.12.3",
"rollup": "^0.48.2",
"rollup": "^0.56.4",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-json": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/generators/dom/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class Block {
}

child(options: BlockOptions) {
return new Block(Object.assign({}, this, options, { parent: this }));
return new Block(Object.assign({}, this, { key: null }, options, { parent: this }));
}

contextualise(expression: Node, context?: string, isEventHandler?: boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function data() {
return { foo: 42 }
}

function encapsulateStyles(node) {
setAttribute(node, "svelte-2794052100", "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

var Nested = window.Nested;

function create_main_fragment(component, state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

var Nested = window.Nested;

function create_main_fragment(component, state) {
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/component-static/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

var Nested = window.Nested;

function create_main_fragment(component, state) {
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/computed-collapsed-if/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function a(x) {
return x * 2;
}
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/css-media-query/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function encapsulateStyles(node) {
setAttribute(node, "svelte-3905933315", "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div;

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/deconflict-globals/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function data_1() {
return {
foo: 'bar'
Expand All @@ -179,7 +180,6 @@ function data_1() {
function oncreate() {
alert(JSON.stringify(data()));
}

function create_main_fragment(component, state) {

return {
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/do-use-dataset/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div, text, div_1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div, text, div_1;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/dont-use-dataset-in-svg/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var svg, g, g_1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var text, p, text_1;

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/event-handlers-custom/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function foo( node, callback ) {
// code goes here
}

var methods = {
foo ( bar ) {
console.log( bar );
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/head-no-whitespace/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var meta, meta_1;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/if-block-no-update/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var if_block_anchor;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/if-block-simple/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var if_block_anchor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/inline-style-optimized/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div, text, div_1, div_1_style_value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var input;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/legacy-default/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var text, p, text_1, text_2, text_3, slot_content_default = component._slotted["default"], slot_content_default_before, slot_content_default_after;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/legacy-input-type/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var input;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/legacy-quote-class/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/media-bindings/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var audio, audio_is_paused = true, audio_updating = false, audio_animationframe;

Expand Down
3 changes: 3 additions & 0 deletions test/js/samples/non-imported-component/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */



function create_main_fragment(component, state) {
var text;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */
function oncreate() {}

function oncreate() {}
function ondestroy() {}

function create_main_fragment(component, state) {

return {
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/setup-method/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

var methods = {
foo ( bar ) {
console.log( bar );
Expand Down
2 changes: 0 additions & 2 deletions test/js/samples/ssr-no-oncreate-etc/expected-bundle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
function preload(input) {
return output;
}

var SvelteComponent = {};

SvelteComponent.data = function() {
return {};
};
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/svg-title/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var svg, title, text;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/title/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var title_value;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/use-elements-as-anchors/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor;

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/window-binding-scroll/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var proto = {
};

/* generated by Svelte vX.Y.Z */

function create_main_fragment(component, state) {
var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1;

Expand Down
15 changes: 15 additions & 0 deletions test/runtime/samples/if-in-keyed-each/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
data: {
items: [
{ id: 1, name: 'one' },
{ id: 2, name: 'two' }
]
},

html: `
<ul>
<li>one</li>
<li>two</li>
</ul>
`
};
7 changes: 7 additions & 0 deletions test/runtime/samples/if-in-keyed-each/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ul>
{{#each items as item @id}}
{{#if item.id}}
<li>{{item.name}}</li>
{{/if}}
{{/each}}
</ul>
Loading