Skip to content

Commit bd79e70

Browse files
Merge pull request #415 from remarkablemark/fix/utilities
fix(client): get template content childNodes in utilities formatDOM
2 parents cb084b8 + 9575d00 commit bd79e70

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.size-limit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
33
"path": "dist/html-dom-parser.min.js",
4-
"limit": "3.89 KB"
4+
"limit": "3.894 KB"
55
}
66
]

lib/client/utilities.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function formatDOM(nodes, parent, directive) {
8383
formatTagName(node.nodeName),
8484
formatAttributes(node.attributes)
8585
);
86-
current.children = formatDOM(node.childNodes, current);
86+
current.children = formatDOM(
87+
// template children are on content
88+
node.content ? node.content.childNodes : node.childNodes,
89+
current
90+
);
8791
break;
8892

8993
case 3:

test/cases/html.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ module.exports = [
227227
}
228228
},
229229

230+
// template tag
231+
{
232+
name: 'empty template',
233+
data: '<template></template>'
234+
},
235+
{
236+
name: 'template with content',
237+
data: '<template><article><p>Test</p></article></template>'
238+
},
239+
230240
// style tag
231241
{
232242
name: 'empty style',

0 commit comments

Comments
 (0)