mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
Merge pull request #1822 from aphitiel/gh-1743
move resize handler from _beforecreate to _after.. (fixes #1743)
This commit is contained in:
commit
79ea0bd43c
@ -529,7 +529,7 @@ export default class ElementWrapper extends Wrapper {
|
||||
renderer.hasComplexBindings = true;
|
||||
|
||||
block.builders.hydrate.addLine(
|
||||
`#component.root._beforecreate.push(${handler});`
|
||||
`#component.root._aftercreate.push(${handler});`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -48,6 +48,8 @@ export function tryToReadFile(file) {
|
||||
export const virtualConsole = new jsdom.VirtualConsole();
|
||||
const { window } = new jsdom.JSDOM('<main></main>', {virtualConsole});
|
||||
global.document = window.document;
|
||||
global.getComputedStyle = window.getComputedStyle;
|
||||
global.navigator = {userAgent: 'fake'};
|
||||
|
||||
export function env() {
|
||||
window._svelteTransitionManager = null;
|
||||
|
@ -12,7 +12,7 @@ function create_main_fragment(component, ctx) {
|
||||
c() {
|
||||
div = createElement("div");
|
||||
div.textContent = "some content";
|
||||
component.root._beforecreate.push(div_resize_handler);
|
||||
component.root._aftercreate.push(div_resize_handler);
|
||||
},
|
||||
|
||||
m(target, anchor) {
|
||||
|
@ -0,0 +1,8 @@
|
||||
export default {
|
||||
'skip-ssr': true,
|
||||
|
||||
test(assert, component, target) {
|
||||
assert.ok(component.onstateRanBeforeOncreate);
|
||||
assert.ok(!component.onupdateRanBeforeOncreate);
|
||||
}
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
<div bind:offsetWidth=width></div>
|
||||
<script>
|
||||
export default {
|
||||
onstate() {
|
||||
this.onstateRan = true;
|
||||
},
|
||||
|
||||
onupdate() {
|
||||
this.onupdateRan = true;
|
||||
},
|
||||
|
||||
oncreate() {
|
||||
this.onstateRanBeforeOncreate = this.onstateRan;
|
||||
this.onupdateRanBeforeOncreate = this.onupdateRan;
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user