@begin/enhance
Advanced tools
Comparing version 0.0.3 to 0.0.4
50
index.js
@@ -1,2 +0,1 @@ | ||
import { existsSync } from 'fs' | ||
import path from 'path' | ||
@@ -14,6 +13,6 @@ import { parse, parseFragment as fragment, serialize } from 'parse5' | ||
function html(strings, ...values) { | ||
return function html(strings, ...values) { | ||
const doc = parse(render(strings, ...values)) | ||
const body = doc.childNodes[0].childNodes[1] | ||
const customElements = processCustomElements(doc, templates) | ||
const customElements = processCustomElements(body, templates) | ||
const moduleNames = [...new Set(customElements.map(node => node.tagName))] | ||
@@ -24,4 +23,2 @@ const scripts = fragment(moduleNames.map(name => script(modules, name)).join('')) | ||
} | ||
return html | ||
} | ||
@@ -81,29 +78,34 @@ | ||
slots.forEach(slot => { | ||
for (let i=0; i < slots.length; i++) { | ||
const slot = slots[i] | ||
const slotAttrs = slot.attrs || [] | ||
let hasSlotName = false | ||
slotAttrs.forEach(attr => { | ||
for (let i=0; i < slotAttrs.length; i++) { | ||
const attr = slotAttrs[i] | ||
if (attr.name === 'name') { | ||
hasSlotName = true | ||
const slotName = attr.value | ||
inserts.forEach(insert => { | ||
for (let i=0; i < inserts.length; i ++) { | ||
const insert = inserts[i] | ||
const insertAttrs = insert.attrs || [] | ||
insertAttrs.forEach(attr => { | ||
if (attr.name === 'slot') { | ||
const insertSlot = attr.value | ||
if (insertSlot === slotName) { | ||
const slotParentChildNodes = slot.parentNode.childNodes | ||
slotParentChildNodes.splice( | ||
slotParentChildNodes | ||
.indexOf(slot), | ||
1, | ||
insert | ||
) | ||
} | ||
for (let i=0; i < insertAttrs.length; i++) { | ||
const attr = insertAttrs[i] | ||
const insertSlot = attr.value | ||
if (insertSlot === slotName) { | ||
const slotParentChildNodes = slot.parentNode.childNodes | ||
slotParentChildNodes.splice( | ||
slotParentChildNodes | ||
.indexOf(slot), | ||
1, | ||
insert | ||
) | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
@@ -120,3 +122,3 @@ if (!hasSlotName) { | ||
} | ||
}) | ||
} | ||
} | ||
@@ -123,0 +125,0 @@ |
{ | ||
"name": "@begin/enhance", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Custom Element Server-side rendering CESR", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
12262
2