mirror of https://github.com/sveltejs/svelte
[fix]: remove double up initialization on svelte:element (#8142)
* fixed double up initialization on svelte:element elements * updated test and fixed bug * update other svelte:element test * removed whitespace * refactor * correctly update expected ouput resulting from #7938 * remove .solo Co-authored-by: Yuichiro Yamashita <xydybaseball@gmail.com>pull/7790/head
parent
14d09a0850
commit
c9e98e6bba
@ -0,0 +1,168 @@
|
|||||||
|
/* generated by Svelte vX.Y.Z */
|
||||||
|
import {
|
||||||
|
SvelteComponent,
|
||||||
|
append,
|
||||||
|
assign,
|
||||||
|
bubble,
|
||||||
|
detach,
|
||||||
|
element,
|
||||||
|
empty,
|
||||||
|
get_spread_update,
|
||||||
|
init,
|
||||||
|
insert,
|
||||||
|
listen,
|
||||||
|
noop,
|
||||||
|
run_all,
|
||||||
|
safe_not_equal,
|
||||||
|
set_attributes,
|
||||||
|
set_custom_element_data_map
|
||||||
|
} from "svelte/internal";
|
||||||
|
|
||||||
|
function create_dynamic_element(ctx) {
|
||||||
|
let svelte_element1;
|
||||||
|
let svelte_element0;
|
||||||
|
let mounted;
|
||||||
|
let dispose;
|
||||||
|
let svelte_element0_levels = [{ class: "inner" }];
|
||||||
|
let svelte_element0_data = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < svelte_element0_levels.length; i += 1) {
|
||||||
|
svelte_element0_data = assign(svelte_element0_data, svelte_element0_levels[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let svelte_element1_levels = [{ class: "outer" }];
|
||||||
|
let svelte_element1_data = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < svelte_element1_levels.length; i += 1) {
|
||||||
|
svelte_element1_data = assign(svelte_element1_data, svelte_element1_levels[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
c() {
|
||||||
|
svelte_element1 = element("a");
|
||||||
|
svelte_element0 = element("span");
|
||||||
|
|
||||||
|
if ((/-/).test("span")) {
|
||||||
|
set_custom_element_data_map(svelte_element0, svelte_element0_data);
|
||||||
|
} else {
|
||||||
|
set_attributes(svelte_element0, svelte_element0_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((/-/).test("a")) {
|
||||||
|
set_custom_element_data_map(svelte_element1, svelte_element1_data);
|
||||||
|
} else {
|
||||||
|
set_attributes(svelte_element1, svelte_element1_data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
m(target, anchor) {
|
||||||
|
insert(target, svelte_element1, anchor);
|
||||||
|
append(svelte_element1, svelte_element0);
|
||||||
|
|
||||||
|
if (!mounted) {
|
||||||
|
dispose = [
|
||||||
|
listen(svelte_element0, "keydown", /*keydown_handler_1*/ ctx[2]),
|
||||||
|
listen(svelte_element0, "keyup", /*keyup_handler_1*/ ctx[3]),
|
||||||
|
listen(svelte_element1, "keydown", /*keydown_handler*/ ctx[0]),
|
||||||
|
listen(svelte_element1, "keyup", /*keyup_handler*/ ctx[1])
|
||||||
|
];
|
||||||
|
|
||||||
|
mounted = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
p(ctx, dirty) {
|
||||||
|
svelte_element0_data = get_spread_update(svelte_element0_levels, [{ class: "inner" }]);
|
||||||
|
|
||||||
|
if ((/-/).test("span")) {
|
||||||
|
set_custom_element_data_map(svelte_element0, svelte_element0_data);
|
||||||
|
} else {
|
||||||
|
set_attributes(svelte_element0, svelte_element0_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
svelte_element1_data = get_spread_update(svelte_element1_levels, [{ class: "outer" }]);
|
||||||
|
|
||||||
|
if ((/-/).test("a")) {
|
||||||
|
set_custom_element_data_map(svelte_element1, svelte_element1_data);
|
||||||
|
} else {
|
||||||
|
set_attributes(svelte_element1, svelte_element1_data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
d(detaching) {
|
||||||
|
if (detaching) detach(svelte_element1);
|
||||||
|
mounted = false;
|
||||||
|
run_all(dispose);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_fragment(ctx) {
|
||||||
|
let previous_tag = "a";
|
||||||
|
let svelte_element_anchor;
|
||||||
|
let svelte_element = "a" && create_dynamic_element(ctx);
|
||||||
|
|
||||||
|
return {
|
||||||
|
c() {
|
||||||
|
if (svelte_element) svelte_element.c();
|
||||||
|
svelte_element_anchor = empty();
|
||||||
|
},
|
||||||
|
m(target, anchor) {
|
||||||
|
if (svelte_element) svelte_element.m(target, anchor);
|
||||||
|
insert(target, svelte_element_anchor, anchor);
|
||||||
|
},
|
||||||
|
p(ctx, [dirty]) {
|
||||||
|
if ("a") {
|
||||||
|
if (!previous_tag) {
|
||||||
|
svelte_element = create_dynamic_element(ctx);
|
||||||
|
svelte_element.c();
|
||||||
|
svelte_element.m(svelte_element_anchor.parentNode, svelte_element_anchor);
|
||||||
|
} else if (safe_not_equal(previous_tag, "a")) {
|
||||||
|
svelte_element.d(1);
|
||||||
|
svelte_element = create_dynamic_element(ctx);
|
||||||
|
svelte_element.c();
|
||||||
|
svelte_element.m(svelte_element_anchor.parentNode, svelte_element_anchor);
|
||||||
|
} else {
|
||||||
|
svelte_element.p(ctx, dirty);
|
||||||
|
}
|
||||||
|
} else if (previous_tag) {
|
||||||
|
svelte_element.d(1);
|
||||||
|
svelte_element = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
previous_tag = "a";
|
||||||
|
},
|
||||||
|
i: noop,
|
||||||
|
o: noop,
|
||||||
|
d(detaching) {
|
||||||
|
if (detaching) detach(svelte_element_anchor);
|
||||||
|
if (svelte_element) svelte_element.d(detaching);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function instance($$self) {
|
||||||
|
function keydown_handler(event) {
|
||||||
|
bubble.call(this, $$self, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyup_handler(event) {
|
||||||
|
bubble.call(this, $$self, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function keydown_handler_1(event) {
|
||||||
|
bubble.call(this, $$self, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyup_handler_1(event) {
|
||||||
|
bubble.call(this, $$self, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [keydown_handler, keyup_handler, keydown_handler_1, keyup_handler_1];
|
||||||
|
}
|
||||||
|
|
||||||
|
class Component extends SvelteComponent {
|
||||||
|
constructor(options) {
|
||||||
|
super();
|
||||||
|
init(this, options, instance, create_fragment, safe_not_equal, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Component;
|
@ -0,0 +1,3 @@
|
|||||||
|
<svelte:element class="outer" this="a" on:keydown on:keyup>
|
||||||
|
<svelte:element class="inner" this="span" on:keydown on:keyup></svelte:element>
|
||||||
|
</svelte:element>
|
Loading…
Reference in new issue