Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
QUnit.test('A tag with a double-quoted empty', function(assert) {
let tokens = tokenize('<div id="">');
assert.deepEqual(tokens, [startTag('div', [['id', '', true]])]);
});
</div>
QUnit.test('tokens: Chars start-tag Chars', function(assert) {
let tokens = tokenize('Chars<div>Chars', { loc: true });
assert.deepEqual(tokens, [
locInfo(chars('Chars'), 1, 0, 1, 5),
locInfo(startTag('div'), 1, 5, 1, 10),
locInfo(chars('Chars'), 1, 10, 1, 15)
]);
});
</div>
QUnit.test('A tag with a double-quoted attribute', function(assert) {
let tokens = tokenize('<div id="foo">');
assert.deepEqual(tokens, [startTag('div', [['id', 'foo', true]])]);
});
</div>
QUnit.test('tokens: comment start-tag Chars end-tag', function(assert) {
let tokens = tokenize(
'<div>Chars\n</div>',
{ loc: true }
);
assert.deepEqual(tokens, [
locInfo(comment(' multline\ncomment '), 1, 0, 2, 11),
locInfo(startTag('div', [['foo', 'bar', false]]), 2, 11, 2, 24),
locInfo(chars('Chars\n'), 2, 24, 3, 0),
locInfo(endTag('div'), 3, 0, 3, 6)
]);
});
QUnit.test('A newline immediately following a <textarea> tag is stripped', function(assert) {
let tokens = tokenize("<textarea>\nhello</textarea>");
assert.deepEqual(tokens, [startTag('textarea'), chars('hello'), endTag('textarea')]);
});
QUnit.test('A self-closing tag', function(assert) {
let tokens = tokenize('<img>');
assert.deepEqual(tokens, [startTag('img', [], true)]);
});
QUnit.test('A tag with capitalization in attributes', function(assert) {
let tokens = tokenize('<svg viewBox="0 0 0 0">');
assert.deepEqual(tokens, [startTag('svg', [['viewBox', '0 0 0 0', true]])]);
});
</svg>
QUnit.test('A newline immediately following a <pre> tag is stripped', function(assert) {
let tokens = tokenize("<pre>\nhello</pre>");
assert.deepEqual(tokens, [startTag('pre'), chars('hello'), endTag('pre')]);
});
</pre>
QUnit.test('A newline immediately following a <pre> tag is stripped', function(assert) {
let tokens = tokenize("<pre>\nhello</pre>");
assert.deepEqual(tokens, [startTag('PRE'), chars('hello'), endTag('PRE')]);
});
</pre>
function generateTokens(containerOrHTML) {
if (typeof containerOrHTML === 'string') {
return {
tokens: tokenize(containerOrHTML),
html: containerOrHTML
};
} else {
return {
tokens: tokenize(containerOrHTML.innerHTML),
html: containerOrHTML.innerHTML
};
}
}