Merge pull request #1822 from aphitiel/gh-1743

move resize handler from _beforecreate to _after.. (fixes #1743)
pull/1887/head
Rich Harris 6 years ago committed by GitHub
commit 79ea0bd43c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -529,7 +529,7 @@ export default class ElementWrapper extends Wrapper {
renderer.hasComplexBindings = true; renderer.hasComplexBindings = true;
block.builders.hydrate.addLine( 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(); export const virtualConsole = new jsdom.VirtualConsole();
const { window } = new jsdom.JSDOM('<main></main>', {virtualConsole}); const { window } = new jsdom.JSDOM('<main></main>', {virtualConsole});
global.document = window.document; global.document = window.document;
global.getComputedStyle = window.getComputedStyle;
global.navigator = {userAgent: 'fake'};
export function env() { export function env() {
window._svelteTransitionManager = null; window._svelteTransitionManager = null;

@ -12,7 +12,7 @@ function create_main_fragment(component, ctx) {
c() { c() {
div = createElement("div"); div = createElement("div");
div.textContent = "some content"; div.textContent = "some content";
component.root._beforecreate.push(div_resize_handler); component.root._aftercreate.push(div_resize_handler);
}, },
m(target, anchor) { 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…
Cancel
Save