You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/parse.js
+55-6Lines changed: 55 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -303,12 +303,6 @@ test('parse', function (t) {
303
303
children: []
304
304
}],'should not explode on trailing whitespace');
305
305
306
-
html=' Hi There ';
307
-
parsed=HTML.parse(html);
308
-
t.deepEqual(parsed,[{
309
-
type: 'text',content: ' Hi There '
310
-
}],'should handle text nodes at the top-level');
311
-
312
306
html='<div>Hi</div> There ';
313
307
parsed=HTML.parse(html);
314
308
t.deepEqual(parsed,[{
@@ -323,6 +317,26 @@ test('parse', function (t) {
323
317
type: 'text',content: ' There '
324
318
}],'should handle trailing text nodes at the top-level');
325
319
320
+
html='Hi <div>There</div>';
321
+
parsed=HTML.parse(html);
322
+
t.deepEqual(parsed,[{
323
+
type: 'text',content: 'Hi '
324
+
},{
325
+
type: 'tag',
326
+
name: 'div',
327
+
attrs: {},
328
+
voidElement: false,
329
+
children: [
330
+
{type: 'text',content: 'There'}
331
+
]
332
+
}],'should handle leading text nodes at the top-level');
333
+
334
+
html='Hi There';
335
+
parsed=HTML.parse(html);
336
+
t.deepEqual(parsed,[{
337
+
type: 'text',content: 'Hi There'
338
+
}],'should handle plain strings of text with no tags');
339
+
326
340
html='<div>Hi</div> There <span>something</span> <a></a>else ';
327
341
parsed=HTML.parse(html);
328
342
t.deepEqual(parsed,[{
@@ -391,6 +405,41 @@ test('parse', function (t) {
391
405
voidElement: false,children: [{content: '\n !function() {\n var cookies = document.cookie ? document.cookie.split(\';\') : [];\n // | this less than is triggering probems\n for (var i = 0; i ',type: 'text'}]
392
406
}],'should parse a script tag');
393
407
408
+
html='<div>Hi</span>There</div>';
409
+
parsed=HTML.parse(html);
410
+
t.deepEqual(parsed,[{
411
+
type: 'tag',
412
+
name: 'div',
413
+
attrs: {},
414
+
voidElement: false,
415
+
children: [
416
+
{type: 'text',content: 'Hi'},
417
+
{type: 'text',content: 'There'}
418
+
]
419
+
}],'should skip over closing tags that don\'t match the current tag name');
0 commit comments