Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade packages #79

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@babel/preset-env": "^7.1.0",
"@babel/preset-typescript": "^7.1.0",
"@types/jest": "^23.3.7",
"@types/lodash": "^4.14.168",
"@types/lodash": "<4.14.180",
"@types/uuid": "^3.4.6",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
Expand All @@ -40,7 +40,7 @@
"ts-loader": "^5.2.1",
"tslint": "^5.11.0",
"tslint-loader": "^3.6.0",
"typescript": "^3.1.1",
"typescript": "~3.5",
"typescript-babel-jest": "^1.0.5"
},
"resolutions": {
Expand Down
16 changes: 8 additions & 8 deletions src/serializationStrategies/XpathRangeSelector/xpath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ const floatThroughText = (element: Node, offset: number, container: Node): [Node

const resolveToNextElementOffsetIfPossible = (element: Node, offset: number) => {
if (isTextOrTextHighlightOrScreenReaderNode(element) && element.parentNode && offset === getMaxOffset(element) && (!element.nextSibling || !isHighlightOrScreenReaderNode(element.nextSibling))) {
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element) + 1];
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element) + 1] as const;
}

return [element, offset];
return [element, offset] as const;
};

const resolveToPreviousElementOffsetIfPossible = (element: Node, offset: number) => {

if (isTextOrTextHighlightOrScreenReaderNode(element) && element.parentNode && offset === 0 && (!element.previousSibling || !isHighlightOrScreenReaderNode(element.previousSibling))) {
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element)];
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element)] as const;
}

return [element, offset];
return [element, offset] as const;
};

// kinda copied from https://developer.mozilla.org/en-US/docs/Web/XPath/Snippets#getXPathForElement
Expand Down Expand Up @@ -138,15 +138,15 @@ export function getXPathForElement(targetElement: Node, offset: number, referenc
pos = 1;

while (element) {
// highlights in text change the number of nodes in the nodelist,
// highlights in text change the number of nodes in the nodelist,z
// compensate by gobbling adjacent highlights and text
if (isTextOrTextHighlightOrScreenReaderNode(focus) && isTextOrTextHighlightOrScreenReaderNode(element)) {
while (isTextOrTextHighlightOrScreenReaderNode(element)) {
element = element.previousSibling!;
}
pos += 1;
} else {
if (isElementNotHighlight(focus) && isElementNotHighlight(element) && element.nodeName === focus.nodeName) {
if (isElementNotHighlight(focus) && isElementNotHighlight(element) && (element as Node).nodeName === (focus as Node).nodeName) {
pos += 1;
}
element = element.previousSibling!;
Expand Down Expand Up @@ -222,7 +222,7 @@ export function getFirstByXPath(path: string, offset: number, referenceElement:
node = null;
}

if (isElement(node!) && node!.childNodes.length < offset) {
if (isElement(node!) && (node as Node).childNodes.length < offset) {
node = null;
}

Expand All @@ -234,7 +234,7 @@ function followPart(node: Node, part: string) {
const findFirst = (nodeList: NodeList, predicate: (node: Node) => boolean) =>
Array.prototype.find.call(nodeList, (node: Node) => predicate(node));
const findFirstAfter = (nodeList: NodeList, afterThis: Node, predicate: (node: Node) => boolean) => findFirst(
Array.prototype.slice.call(nodeList, Array.prototype.indexOf.call(nodeList, afterThis) + 1),
Array.prototype.slice.call(nodeList, Array.prototype.indexOf.call(nodeList, afterThis) + 1) as unknown as NodeList,
predicate
);

Expand Down
Loading
Loading