From 9dbc571f57be5cfe00b720210b08533bcf8606f9 Mon Sep 17 00:00:00 2001 From: Andrew Worcester Date: Fri, 25 Aug 2017 11:52:09 -0400 Subject: [PATCH 1/2] allow an anchor element to be passed for initial component bootstrap --- src/generators/dom/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 98040fc8f5..4e20b28e3d 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -213,7 +213,7 @@ export default function dom( ${options.dev && `if ( options.hydrate ) throw new Error( 'options.hydrate only works if the component was compiled with the \`hydratable: true\` option' );`} this._fragment.create(); `} - this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null ); + this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, options.anchor || null ); } ${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent` From caa67b5325d3b3e053cfaa1e87524af2344321f9 Mon Sep 17 00:00:00 2001 From: Andrew Worcester Date: Fri, 25 Aug 2017 13:24:08 -0400 Subject: [PATCH 2/2] updated tests to reflect anchor change --- .../samples/collapses-text-around-comments/expected-bundle.js | 2 +- test/js/samples/collapses-text-around-comments/expected.js | 2 +- test/js/samples/computed-collapsed-if/expected-bundle.js | 2 +- test/js/samples/computed-collapsed-if/expected.js | 2 +- test/js/samples/css-media-query/expected-bundle.js | 2 +- test/js/samples/css-media-query/expected.js | 2 +- test/js/samples/each-block-changed-check/expected-bundle.js | 2 +- test/js/samples/each-block-changed-check/expected.js | 2 +- test/js/samples/event-handlers-custom/expected-bundle.js | 2 +- test/js/samples/event-handlers-custom/expected.js | 2 +- test/js/samples/if-block-no-update/expected-bundle.js | 2 +- test/js/samples/if-block-no-update/expected.js | 2 +- test/js/samples/if-block-simple/expected-bundle.js | 2 +- test/js/samples/if-block-simple/expected.js | 2 +- test/js/samples/legacy-input-type/expected-bundle.js | 2 +- test/js/samples/legacy-input-type/expected.js | 2 +- test/js/samples/non-imported-component/expected-bundle.js | 2 +- test/js/samples/non-imported-component/expected.js | 2 +- .../js/samples/onrender-onteardown-rewritten/expected-bundle.js | 2 +- test/js/samples/onrender-onteardown-rewritten/expected.js | 2 +- test/js/samples/setup-method/expected-bundle.js | 2 +- test/js/samples/setup-method/expected.js | 2 +- test/js/samples/use-elements-as-anchors/expected-bundle.js | 2 +- test/js/samples/use-elements-as-anchors/expected.js | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index b24896ca8a..49416ae54c 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -237,7 +237,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 6bb93f0f89..dec0b39b8e 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -73,7 +73,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 385e2e4fd8..cce5a11ef6 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -184,7 +184,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index f28a843cad..91e45d4057 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -44,7 +44,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index cc643a64c1..721ea74084 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -219,7 +219,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index bb51bba637..1431442a3d 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -59,7 +59,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index ec91d9f270..51a29b34f3 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -331,7 +331,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 1cadd16f18..f7ad013def 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -158,7 +158,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index c298f39038..004eeb6132 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -228,7 +228,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index 21454cfd98..e64db2d074 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -68,7 +68,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index 96fa7ee3e7..cefae921f5 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -270,7 +270,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index fe393dda7a..0f4dcf49e7 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -106,7 +106,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index e36acc90b7..d34df63b58 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -246,7 +246,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index 6e3a378337..51c9064f95 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -82,7 +82,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index 074fcb3ee5..2dd18e4215 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -204,7 +204,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js index 649651d41b..ebadff470f 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -46,7 +46,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index ddfd1cd82d..045d00b6f9 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -226,7 +226,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } if ( !options._root ) { diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index a7944a3976..a335e999b9 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -74,7 +74,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } if ( !options._root ) { diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index a8e48098e0..eeb33a8bd1 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -191,7 +191,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } if ( !options._root ) { diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index ba6c744ee2..4116f8fd06 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -51,7 +51,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } if ( !options._root ) { diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 4f4a638d8f..903904bcbd 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -193,7 +193,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index a2111f98e8..2535d611c8 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -53,7 +53,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index 4b7feda54d..ad4b5ee79b 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -430,7 +430,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } } diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 45f339c416..fba00a491f 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -266,7 +266,7 @@ function SvelteComponent ( options ) { if ( options.target ) { this._fragment.create(); - this._fragment.mount( options.target, null ); + this._fragment.mount( options.target, options.anchor || null ); } }