Skip to content

Commit

Permalink
fix(client): check for "template" in utilities formatDOM
Browse files Browse the repository at this point in the history
Fixes #417
  • Loading branch information
remarkablemark committed Mar 6, 2023
1 parent 2fb26f5 commit 748cf27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/client/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function formatTagName(tagName) {
function formatDOM(nodes, parent, directive) {
parent = parent || null;
var result = [];
var tagName;

for (var index = 0, len = nodes.length; index < len; index++) {
var node = nodes[index];
Expand All @@ -78,14 +79,12 @@ function formatDOM(nodes, parent, directive) {
// set the node data given the type
switch (node.nodeType) {
case 1:
tagName = formatTagName(node.nodeName);
// script, style, or tag
current = new Element(
formatTagName(node.nodeName),
formatAttributes(node.attributes)
);
current = new Element(tagName, formatAttributes(node.attributes));
current.children = formatDOM(
// template children are on content
node.content ? node.content.childNodes : node.childNodes,
tagName === 'template' ? node.content.childNodes : node.childNodes,
current
);
break;
Expand Down
4 changes: 4 additions & 0 deletions test/cases/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ module.exports = [
name: 'meta with attribute',
data: '<meta charset="utf-8">'
},
{
name: 'meta with closing tag',
data: '<meta name="author" content="John Doe Mason" />'
},
{
name: 'textarea with value',
data: '<textarea>value</textarea>'
Expand Down

0 comments on commit 748cf27

Please sign in to comment.