Skip to content

Commit

Permalink
+ <script> markers support
Browse files Browse the repository at this point in the history
  • Loading branch information
Lcfvs committed Sep 4, 2021
1 parent aa47288 commit 1e3ca91
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
17 changes: 15 additions & 2 deletions lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ const tokenize = node => {
const map = new Map()

for (const [key, current] of search(node).entries()) {
const { nodeName } = current

if (current.nodeName === 'TITLE') {
if (nodeName === 'TITLE') {
const tokens = identify(escaped, current.innerHTML)

if (tokens.length) {
map.set(key, { tokens })
}
} else if (nodeName === 'SCRIPT') {
const tokens = identify(escaped, current.textContent)

if (tokens.length) {
map.set(key, { tokens })
}
Expand Down Expand Up @@ -193,10 +200,16 @@ const content = (tokens, node, template) => {
}

const pick = node => {
if (node.nodeName === 'TITLE') {
const { nodeName } = node

if (nodeName === 'TITLE') {
return [node.firstChild, node.innerHTML]
}

if (nodeName === 'SCRIPT') {
return [node, node.textContent]
}

return [node, node.nodeValue]
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lcf.vs/dom-engine",
"version": "5.2.5",
"version": "5.3.0",
"description": "A composable DOM based template engine",
"type": "module",
"exports": {
Expand Down

0 comments on commit 1e3ca91

Please sign in to comment.