Skip to content

Commit

Permalink
start and end got renamed in parse5's location info
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebmaster committed Mar 5, 2016
1 parent 4703e66 commit 333ca27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions lib/jsdom.js
Expand Up @@ -15,7 +15,6 @@ const domToHtml = require("./jsdom/browser/domtohtml").domToHtml;
const Window = require("./jsdom/browser/Window");
const resourceLoader = require("./jsdom/browser/resource-loader");
const VirtualConsole = require("./jsdom/virtual-console");
const locationInfo = require("./jsdom/living/helpers/internal-constants").locationInfo;
const idlUtils = require("./jsdom/living/generated/utils");

require("./jsdom/living"); // Enable living standard features
Expand All @@ -41,7 +40,7 @@ exports.createCookieJar = function () {
};

exports.nodeLocation = function (node) {
return idlUtils.implForWrapper(node)[locationInfo];
return idlUtils.implForWrapper(node).__location;
};

exports.reconfigureWindow = function (window, newProps) {
Expand Down
1 change: 0 additions & 1 deletion lib/jsdom/living/helpers/internal-constants.js
Expand Up @@ -2,7 +2,6 @@
const SymbolTree = require("symbol-tree");

exports.cloningSteps = Symbol("cloning steps");
exports.locationInfo = Symbol("location info");
exports.accept = Symbol("accept");
exports.requestManager = Symbol("request manager");
exports.pool = Symbol("pool");
Expand Down
20 changes: 10 additions & 10 deletions test/jsdom/node-location.js
Expand Up @@ -12,21 +12,21 @@ describe("jsdom/node-location", () => {
const el = document.querySelector("p");

const location = jsdom.nodeLocation(el);
assert.strictEqual(location.start, 0);
assert.strictEqual(location.end, 12);
assert.strictEqual(location.startTag.start, 0);
assert.strictEqual(location.startTag.end, 3);
assert.strictEqual(location.endTag.start, 8);
assert.strictEqual(location.endTag.end, 12);
assert.strictEqual(location.startOffset, 0);
assert.strictEqual(location.endOffset, 12);
assert.strictEqual(location.startTag.startOffset, 0);
assert.strictEqual(location.startTag.endOffset, 3);
assert.strictEqual(location.endTag.startOffset, 8);
assert.strictEqual(location.endTag.endOffset, 12);
});

specify("jsdom.nodeLocation on a text node", () => {
const document = jsdom.jsdom("<p>Hello</p>");
const el = document.querySelector("p");

const location = jsdom.nodeLocation(el.firstChild);
assert.strictEqual(location.start, 3);
assert.strictEqual(location.end, 8);
assert.strictEqual(location.startOffset, 3);
assert.strictEqual(location.endOffset, 8);
});

specify("jsdom.nodeLocation on a void element", () => {
Expand All @@ -36,7 +36,7 @@ describe("jsdom/node-location", () => {
const el = document.querySelector("img");

const location = jsdom.nodeLocation(el);
assert.strictEqual(location.start, 13);
assert.strictEqual(location.end, 32);
assert.strictEqual(location.startOffset, 15);
assert.strictEqual(location.endOffset, 34);
});
});

0 comments on commit 333ca27

Please sign in to comment.