0
0
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:
Rich Harris 2018-12-15 18:14:06 -05:00 committed by GitHub
commit 79ea0bd43c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 2 deletions

View File

@ -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});`
);
}
});

View File

@ -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;

View File

@ -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) {

View File

@ -0,0 +1,8 @@
export default {
'skip-ssr': true,
test(assert, component, target) {
assert.ok(component.onstateRanBeforeOncreate);
assert.ok(!component.onupdateRanBeforeOncreate);
}
};

View File

@ -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>