71d22131e6
Fixes #34620. git-svn-id: https://develop.svn.wordpress.org/trunk@35574 602fd350-edb4-49c9-b593-d223f7449a82
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
ModuleLoader.require([
|
|
"tinymce/dom/NodePath"
|
|
], function(NodePath) {
|
|
module("tinymce.dom.NodePath", {});
|
|
|
|
function getRoot() {
|
|
return document.getElementById('view');
|
|
}
|
|
|
|
function setupHtml(html) {
|
|
getRoot().innerHTML = html;
|
|
}
|
|
|
|
test("create", function() {
|
|
setupHtml('<p>a<b>12<input></b></p>');
|
|
|
|
deepEqual(NodePath.create(getRoot(), getRoot().firstChild), [0]);
|
|
deepEqual(NodePath.create(getRoot(), getRoot().firstChild.firstChild), [0, 0]);
|
|
deepEqual(NodePath.create(getRoot(), getRoot().firstChild.lastChild.lastChild), [1, 1, 0]);
|
|
});
|
|
|
|
test("resolve", function() {
|
|
setupHtml('<p>a<b>12<input></b></p>');
|
|
|
|
deepEqual(NodePath.resolve(getRoot(), NodePath.create(getRoot(), getRoot().firstChild)), getRoot().firstChild);
|
|
deepEqual(NodePath.resolve(getRoot(), NodePath.create(getRoot(), getRoot().firstChild.firstChild)), getRoot().firstChild.firstChild);
|
|
deepEqual(NodePath.resolve(getRoot(), NodePath.create(getRoot(), getRoot().firstChild.lastChild.lastChild)), getRoot().firstChild.lastChild.lastChild);
|
|
});
|
|
}); |