Token internal - bhsd-harry/wikiparser-node GitHub Wiki
This is an internal document. For visitors, you can now go back to the home page.
// insertAt (main)
var root = Parser.parse('');
root.setAttribute('acceptable', {AstText: 0});
try {
root.insertAt('');
} catch (e) {
assert.strictEqual(
e.message,
'Token cannot insert a AstText at position 1!',
);
}
try {
root.insertAt('', -1);
} catch (e) {
assert.strictEqual(
e.message,
`Token violates the order of acceptable nodes by inserting a child node at position 0!`,
);
}
// removeAt (main)
var root = Parser.parse('a<b>');
root.protectChildren(1);
try {
root.removeAt(-1);
} catch (e) {
assert.strictEqual(
e.message,
'Token cannot remove the child node at position 1!',
);
}
root.setAttribute('acceptable', {AstText: 0, HtmlToken: 1});
try {
root.removeAt(0);
} catch (e) {
assert.strictEqual(
e.message,
`Token violates the order of acceptable nodes by removing the child node at position 0!`,
);
}