From e1b55f0fc3c9b2ceec58c6e5ff8ccf16e04a0c9f Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Thu, 25 Jun 2020 06:17:21 +0800 Subject: [PATCH 1/5] add further cases where {@html} uses an anchor (#5061) --- CHANGELOG.md | 1 + .../render_dom/wrappers/RawMustacheTag.ts | 2 +- .../raw-mustache-as-root/RawMustache.svelte | 5 +++ .../samples/raw-mustache-as-root/_config.js | 33 +++++++++++++++++++ .../samples/raw-mustache-as-root/main.svelte | 17 ++++++++++ .../Component.svelte | 2 ++ .../raw-mustache-before-element/_config.js | 32 +++++++++++++++++- .../raw-mustache-before-element/main.svelte | 18 +++++++++- .../raw-mustache-inside-slot/_config.js | 3 ++ .../raw-mustache-inside-slot/main.svelte | 1 + 10 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 test/runtime/samples/raw-mustache-as-root/RawMustache.svelte create mode 100644 test/runtime/samples/raw-mustache-as-root/_config.js create mode 100644 test/runtime/samples/raw-mustache-as-root/main.svelte create mode 100644 test/runtime/samples/raw-mustache-before-element/Component.svelte create mode 100644 test/runtime/samples/raw-mustache-inside-slot/_config.js create mode 100644 test/runtime/samples/raw-mustache-inside-slot/main.svelte diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ebb458476..9650d9e0d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +* Fix placement of `{@html}` when used at the root of a slot or the root of a component ([#5012](https://github.com/sveltejs/svelte/issues/5012)) * Fix handling of `import`ed value that is used as a store and is also mutated ([#5019](https://github.com/sveltejs/svelte/issues/5019)) * Do not display `a11y-missing-content` warning on elements with `contenteditable` bindings ([#5020](https://github.com/sveltejs/svelte/issues/5020)) * Fix handling of `this` in inline function expressions in the template ([#5033](https://github.com/sveltejs/svelte/issues/5033)) diff --git a/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts b/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts index 1e6213cf02..a5367b207d 100644 --- a/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts +++ b/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts @@ -39,7 +39,7 @@ export default class RawMustacheTagWrapper extends Tag { } else { - const needs_anchor = in_head || (this.next && !this.next.is_dom_node()); + const needs_anchor = in_head || (this.next ? !this.next.is_dom_node() : (!this.parent || !this.parent.is_dom_node())); const html_tag = block.get_unique_name('html_tag'); const html_anchor = needs_anchor && block.get_unique_name('html_anchor'); diff --git a/test/runtime/samples/raw-mustache-as-root/RawMustache.svelte b/test/runtime/samples/raw-mustache-as-root/RawMustache.svelte new file mode 100644 index 0000000000..d94954f49b --- /dev/null +++ b/test/runtime/samples/raw-mustache-as-root/RawMustache.svelte @@ -0,0 +1,5 @@ + + +{@html content} \ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-as-root/_config.js b/test/runtime/samples/raw-mustache-as-root/_config.js new file mode 100644 index 0000000000..c87971a7f0 --- /dev/null +++ b/test/runtime/samples/raw-mustache-as-root/_config.js @@ -0,0 +1,33 @@ +export default { + html: ` + +

Another first line

+

This line should be last.

+ `, + async test({ assert, target, window }) { + const btn = target.querySelector("button"); + const clickEvent = new window.MouseEvent("click"); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

First line

+

This line should be last.

+ ` + ); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

Another first line

+

This line should be last.

+ ` + ); + }, +}; diff --git a/test/runtime/samples/raw-mustache-as-root/main.svelte b/test/runtime/samples/raw-mustache-as-root/main.svelte new file mode 100644 index 0000000000..7ccce0cd9b --- /dev/null +++ b/test/runtime/samples/raw-mustache-as-root/main.svelte @@ -0,0 +1,17 @@ + + + + + + +

This line should be last.

\ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-before-element/Component.svelte b/test/runtime/samples/raw-mustache-before-element/Component.svelte new file mode 100644 index 0000000000..fcabccae48 --- /dev/null +++ b/test/runtime/samples/raw-mustache-before-element/Component.svelte @@ -0,0 +1,2 @@ + +

This line should be last.

\ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-before-element/_config.js b/test/runtime/samples/raw-mustache-before-element/_config.js index 61288cbb52..c87971a7f0 100644 --- a/test/runtime/samples/raw-mustache-before-element/_config.js +++ b/test/runtime/samples/raw-mustache-before-element/_config.js @@ -1,3 +1,33 @@ export default { - html: `

xbaz

` + html: ` + +

Another first line

+

This line should be last.

+ `, + async test({ assert, target, window }) { + const btn = target.querySelector("button"); + const clickEvent = new window.MouseEvent("click"); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

First line

+

This line should be last.

+ ` + ); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

Another first line

+

This line should be last.

+ ` + ); + }, }; diff --git a/test/runtime/samples/raw-mustache-before-element/main.svelte b/test/runtime/samples/raw-mustache-before-element/main.svelte index 69c1d0107d..a022a68e95 100644 --- a/test/runtime/samples/raw-mustache-before-element/main.svelte +++ b/test/runtime/samples/raw-mustache-before-element/main.svelte @@ -1 +1,17 @@ -

{@html 'x'}baz

\ No newline at end of file + + + + + + {@html content} + \ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-inside-slot/_config.js b/test/runtime/samples/raw-mustache-inside-slot/_config.js new file mode 100644 index 0000000000..61288cbb52 --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-slot/_config.js @@ -0,0 +1,3 @@ +export default { + html: `

xbaz

` +}; diff --git a/test/runtime/samples/raw-mustache-inside-slot/main.svelte b/test/runtime/samples/raw-mustache-inside-slot/main.svelte new file mode 100644 index 0000000000..69c1d0107d --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-slot/main.svelte @@ -0,0 +1 @@ +

{@html 'x'}baz

\ No newline at end of file From 0520a10dc0b93b754dc42a2f233efdfbd25fa162 Mon Sep 17 00:00:00 2001 From: Bassam Ismail Date: Thu, 25 Jun 2020 06:13:03 +0530 Subject: [PATCH 2/5] site: check if mapbox key is set before generating the production build (#5057) --- site/rollup.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/rollup.config.js b/site/rollup.config.js index 9cb963a87d..d4efb4eb29 100644 --- a/site/rollup.config.js +++ b/site/rollup.config.js @@ -13,6 +13,10 @@ const mode = process.env.NODE_ENV; const dev = mode === 'development'; const legacy = !!process.env.SAPPER_LEGACY_BUILD; +if (!dev && !process.env.MAPBOX_ACCESS_TOKEN) { + throw new Error('MAPBOX_ACCESS_TOKEN is missing. Please add the token in the .env file before generating the production build.'); +} + const onwarn = (warning, onwarn) => (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) || onwarn(warning); const dedupe = importee => importee === 'svelte' || importee.startsWith('svelte/'); From 1a71e0407905a8f023794fedd752c8e0eec06d2f Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Thu, 25 Jun 2020 20:33:30 +0800 Subject: [PATCH 3/5] fix bind:this, skip checking before adding to binding_callbacks (#5072) --- CHANGELOG.md | 1 + .../render_dom/wrappers/shared/bind_this.ts | 3 +- .../_config.js | 53 +++++++++++++++++++ .../main.svelte | 17 ++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/binding-this-each-block-property-2/_config.js create mode 100644 test/runtime/samples/binding-this-each-block-property-2/main.svelte diff --git a/CHANGELOG.md b/CHANGELOG.md index 9650d9e0d6..8457cd120b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Do not display `a11y-missing-content` warning on elements with `contenteditable` bindings ([#5020](https://github.com/sveltejs/svelte/issues/5020)) * Fix handling of `this` in inline function expressions in the template ([#5033](https://github.com/sveltejs/svelte/issues/5033)) * Update `` with one-way `value` binding when the available `