forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix]: remove double up initialization on svelte:element (sveltejs#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 sveltejs#7938 * remove .solo Co-authored-by: Yuichiro Yamashita <[email protected]>
- Loading branch information
1 parent
14d09a0
commit c9e98e6
Showing
4 changed files
with
212 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
test/js/samples/svelte-element-event-handlers/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters