diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..0359c42
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,7 @@
+[*]
+charset = utf-8
+end_of_line = lf
+
+[{*.js,*.json}]
+indent_style = space
+indent_size = 2
diff --git a/.gitignore b/.gitignore
index f2a529e..fe92c03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
node_modules
.DS_Store
-coverage
\ No newline at end of file
+coverage
+.idea/
diff --git a/index.js b/index.js
index f82cd94..d205389 100644
--- a/index.js
+++ b/index.js
@@ -16,12 +16,12 @@ function createSlots(slots) {
return {
c: noop,
m: function mount(target, anchor) {
- insert(target, element.cloneNode(true), anchor);
+ insert(target, element.cloneNode(true), anchor);
},
- d: function destroy(detaching) {
- if (detaching && element.innerHTML){
+ d: function destroy(detaching) {
+ if (detaching && element.innerHTML){
detach(element);
- }
+ }
},
l: noop,
};
@@ -42,7 +42,7 @@ export default function(opts){
let link = document.createElement('link');
link.setAttribute("href",opts.href)
link.setAttribute("rel","stylesheet")
- root.appendChild(link);
+ root.appendChild(link);
}
if(opts.shadow){
this._root = document.createElement('div')
@@ -82,7 +82,7 @@ export default function(opts){
}
try{ this.elem.$destroy()}catch(err){} // detroy svelte element when removed from dom
}
-
+
unwrap(from){
let node = document.createDocumentFragment();
while (from.firstChild) {
@@ -95,7 +95,7 @@ export default function(opts){
const namedSlots = this.querySelectorAll('[slot]')
let slots = {}
namedSlots.forEach(n=>{
- slots[n.slot] = this.unwrap(n)
+ slots[n.slot] = n
this.removeChild(n)
})
if(this.innerHTML.length){
@@ -144,6 +144,6 @@ export default function(opts){
this.elem.$set({[name]:newValue})
}
}
- }
+ }
window.customElements.define(opts.tagname, Wrapper);
}
diff --git a/tests/tag.test.js b/tests/tag.test.js
index b746d02..97d03f8 100644
--- a/tests/tag.test.js
+++ b/tests/tag.test.js
@@ -42,21 +42,21 @@ describe("Component Wrapper shadow false", () => {
el = document.createElement('div')
el.innerHTML = `Main H1
Main H1
Main H1
Main H1
Nested
Main H1
Nested
Main H1
Nested