From 46b1843c4e39978800def6c0048ef98b31bc801f Mon Sep 17 00:00:00 2001 From: Zephraph Date: Sat, 27 Apr 2019 16:29:49 -0400 Subject: [PATCH] Add another slot test, add other element usage in test --- .../no-shadow-dom-with-slots/AsElement.svelte | 3 + .../AsImported.svelte | 3 + .../no-shadow-dom-with-slots/main.svelte | 6 +- .../no-shadow-dom-with-slots/other.svelte | 3 - .../samples/no-shadow-dom-with-slots/test.js | 2 +- .../AsElement.svelte | 3 + .../AsImport.svelte | 3 + .../_config.js | 6 + .../expected.js | 109 ++++++++++++++++++ .../input.svelte | 9 ++ 10 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 test/custom-elements/samples/no-shadow-dom-with-slots/AsElement.svelte create mode 100644 test/custom-elements/samples/no-shadow-dom-with-slots/AsImported.svelte delete mode 100644 test/custom-elements/samples/no-shadow-dom-with-slots/other.svelte create mode 100644 test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsElement.svelte create mode 100644 test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsImport.svelte create mode 100644 test/js/samples/css-custom-element-no-shadow-dom-with-slots/_config.js create mode 100644 test/js/samples/css-custom-element-no-shadow-dom-with-slots/expected.js create mode 100644 test/js/samples/css-custom-element-no-shadow-dom-with-slots/input.svelte diff --git a/test/custom-elements/samples/no-shadow-dom-with-slots/AsElement.svelte b/test/custom-elements/samples/no-shadow-dom-with-slots/AsElement.svelte new file mode 100644 index 0000000000..0d53cfe766 --- /dev/null +++ b/test/custom-elements/samples/no-shadow-dom-with-slots/AsElement.svelte @@ -0,0 +1,3 @@ + + +

\ No newline at end of file diff --git a/test/custom-elements/samples/no-shadow-dom-with-slots/AsImported.svelte b/test/custom-elements/samples/no-shadow-dom-with-slots/AsImported.svelte new file mode 100644 index 0000000000..baa5da90f1 --- /dev/null +++ b/test/custom-elements/samples/no-shadow-dom-with-slots/AsImported.svelte @@ -0,0 +1,3 @@ + + +

\ No newline at end of file diff --git a/test/custom-elements/samples/no-shadow-dom-with-slots/main.svelte b/test/custom-elements/samples/no-shadow-dom-with-slots/main.svelte index 3942b70e7a..2e46f8e57c 100644 --- a/test/custom-elements/samples/no-shadow-dom-with-slots/main.svelte +++ b/test/custom-elements/samples/no-shadow-dom-with-slots/main.svelte @@ -1,7 +1,9 @@ -Hello world \ No newline at end of file +Hello +world \ No newline at end of file diff --git a/test/custom-elements/samples/no-shadow-dom-with-slots/other.svelte b/test/custom-elements/samples/no-shadow-dom-with-slots/other.svelte deleted file mode 100644 index a9d62e355a..0000000000 --- a/test/custom-elements/samples/no-shadow-dom-with-slots/other.svelte +++ /dev/null @@ -1,3 +0,0 @@ - - -

\ No newline at end of file diff --git a/test/custom-elements/samples/no-shadow-dom-with-slots/test.js b/test/custom-elements/samples/no-shadow-dom-with-slots/test.js index 494cff4ce5..2c6d5d91d8 100644 --- a/test/custom-elements/samples/no-shadow-dom-with-slots/test.js +++ b/test/custom-elements/samples/no-shadow-dom-with-slots/test.js @@ -6,7 +6,7 @@ export default function (target) { target }); - assert.equal(target.innerHTML, '

Hello world!

'); + assert.equal(target.innerHTML, '

Hello

world

'); const el = target.querySelector('custom-element'); assert.equal(el.innerText, "Hello world!"); diff --git a/test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsElement.svelte b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsElement.svelte new file mode 100644 index 0000000000..870b8976ab --- /dev/null +++ b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsElement.svelte @@ -0,0 +1,3 @@ + + +

\ No newline at end of file diff --git a/test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsImport.svelte b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsImport.svelte new file mode 100644 index 0000000000..6756772688 --- /dev/null +++ b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/AsImport.svelte @@ -0,0 +1,3 @@ + + +

\ No newline at end of file diff --git a/test/js/samples/css-custom-element-no-shadow-dom-with-slots/_config.js b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/_config.js new file mode 100644 index 0000000000..52d689af96 --- /dev/null +++ b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/_config.js @@ -0,0 +1,6 @@ +export default { + options: { + customElement: true, + shadowDom: false + } +}; \ No newline at end of file diff --git a/test/js/samples/css-custom-element-no-shadow-dom-with-slots/expected.js b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/expected.js new file mode 100644 index 0000000000..7eb038c88c --- /dev/null +++ b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/expected.js @@ -0,0 +1,109 @@ +/* generated by Svelte vX.Y.Z */ +import { + SvelteElement, + detach, + element, + init, + insert, + mount_component, + noop, + safe_not_equal, + space, + text +} from "svelte/internal"; +import "./AsElement.svelte"; +import AsImport from "./AsImport.svelte"; + +// (9:0) +function create_default_slot(ctx) { + var t; + + return { + c() { + t = text("world"); + }, + + m(target, anchor) { + insert(target, t, anchor); + }, + + d(detaching) { + if (detaching) { + detach(t); + } + } + }; +} + +function create_fragment(ctx) { + var as_element, t_1, current; + + var asimport = new AsImport({ + props: { + $$slots: { default: [create_default_slot] }, + $$scope: { ctx } + } + }); + + return { + c() { + as_element = element("as-element"); + as_element.textContent = "hello"; + t_1 = space(); + asimport.$$.fragment.c(); + this.c = noop; + }, + + m(target, anchor) { + insert(target, as_element, anchor); + insert(target, t_1, anchor); + mount_component(asimport, target, anchor); + current = true; + }, + + p(changed, ctx) { + var asimport_changes = {}; + if (changed.$$scope) asimport_changes.$$scope = { changed, ctx }; + asimport.$set(asimport_changes); + }, + + i(local) { + if (current) return; + asimport.$$.fragment.i(local); + + current = true; + }, + + o(local) { + asimport.$$.fragment.o(local); + current = false; + }, + + d(detaching) { + if (detaching) { + detach(as_element); + detach(t_1); + } + + asimport.$destroy(detaching); + } + }; +} + +class Component extends SvelteElement { + constructor(options) { + super({ use_shadow_dom: false }); + + init(this, { target: this }, null, create_fragment, safe_not_equal, []); + + if (options) { + if (options.target) { + insert(options.target, this, options.anchor); + } + } + } +} + +customElements.define("custom-element", Component); + +export default Component; \ No newline at end of file diff --git a/test/js/samples/css-custom-element-no-shadow-dom-with-slots/input.svelte b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/input.svelte new file mode 100644 index 0000000000..ffdebd0a55 --- /dev/null +++ b/test/js/samples/css-custom-element-no-shadow-dom-with-slots/input.svelte @@ -0,0 +1,9 @@ + + + + +hello +world