From d27dbae51c85d09a4f60fce6dec42839ac3a423a Mon Sep 17 00:00:00 2001 From: pk Date: Mon, 29 Oct 2018 12:50:48 +0100 Subject: [PATCH 1/2] move resize handler from _beforecreate to _after.. (fixes #1743) --- src/compile/render-dom/wrappers/Element/index.ts | 2 +- test/js/samples/bind-width-height/expected.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts index 47c1bc57f3..290c1b0d6e 100644 --- a/src/compile/render-dom/wrappers/Element/index.ts +++ b/src/compile/render-dom/wrappers/Element/index.ts @@ -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});` ); } }); diff --git a/test/js/samples/bind-width-height/expected.js b/test/js/samples/bind-width-height/expected.js index bb2bf2554a..a401dbce11 100644 --- a/test/js/samples/bind-width-height/expected.js +++ b/test/js/samples/bind-width-height/expected.js @@ -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) { From fd9dc300887ca9565d3b6dda5da73168f895e598 Mon Sep 17 00:00:00 2001 From: pk Date: Sun, 4 Nov 2018 20:25:57 +0100 Subject: [PATCH 2/2] Failing test for #1743 global.getComputedStyle and global.navigator are needed for addResizeListener in shared/dom --- test/helpers.js | 2 ++ .../_config.js | 8 ++++++++ .../main.html | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/_config.js create mode 100644 test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/main.html diff --git a/test/helpers.js b/test/helpers.js index 7a04ff0262..7b1f08bb45 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -48,6 +48,8 @@ export function tryToReadFile(file) { export const virtualConsole = new jsdom.VirtualConsole(); const { window } = new jsdom.JSDOM('
', {virtualConsole}); global.document = window.document; +global.getComputedStyle = window.getComputedStyle; +global.navigator = {userAgent: 'fake'}; export function env() { window._svelteTransitionManager = null; diff --git a/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/_config.js b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/_config.js new file mode 100644 index 0000000000..ff2b87b712 --- /dev/null +++ b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/_config.js @@ -0,0 +1,8 @@ +export default { + 'skip-ssr': true, + + test(assert, component, target) { + assert.ok(component.onstateRanBeforeOncreate); + assert.ok(!component.onupdateRanBeforeOncreate); + } +}; diff --git a/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/main.html b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/main.html new file mode 100644 index 0000000000..d930bbcbbb --- /dev/null +++ b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/main.html @@ -0,0 +1,17 @@ +
+