Add another slot test, add other element usage in test

pull/2516/head
Zephraph 7 years ago
parent 3d9d3a05ec
commit 46b1843c4e

@ -0,0 +1,3 @@
<svelte:options tag="as-element"/>
<h1><slot/></h1>

@ -0,0 +1,3 @@
<svelte:options tag="imported-element"/>
<h2><slot/></h2>

@ -1,7 +1,9 @@
<svelte:options tag="custom-element"/>
<script>
import './other.svelte'
import './AsElement.svelte';
import ImportedElement from './AsImported.svelte';
</script>
<other-element>Hello world</other-element>
<as-element>Hello</as-element>
<ImportedElement>world</ImportedElement>

@ -1,3 +0,0 @@
<svelte:options tag="other-element"/>
<h1><slot/></h1>

@ -6,7 +6,7 @@ export default function (target) {
target
});
assert.equal(target.innerHTML, '<custom-element><other-element><h1>Hello world!</h1></other-element></custom-element>');
assert.equal(target.innerHTML, '<custom-element><as-element><h1>Hello</h1></as-element><imported-element><h2>world</h2></imported-element></custom-element>');
const el = target.querySelector('custom-element');
assert.equal(el.innerText, "Hello world!");

@ -0,0 +1,3 @@
<svelte:options tag="as-element"/>
<h1><slot/><h1>

@ -0,0 +1,3 @@
<svelte:options tag="as-import"/>
<h2><slot/><h2>

@ -0,0 +1,6 @@
export default {
options: {
customElement: true,
shadowDom: false
}
};

@ -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) <AsImport>
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;

@ -0,0 +1,9 @@
<svelte:options tag="custom-element"/>
<script>
import "./AsElement.svelte";
import AsImport from "./AsImport.svelte";
</script>
<as-element>hello</as-element>
<AsImport>world</AsImport>
Loading…
Cancel
Save