@qualweb/qw-element
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -34,4 +34,6 @@ /// <reference types="@qualweb/types" /> | ||
getElementNextSibling(): QWElement | null; | ||
getPreviousSibling(): QWElement | string | undefined | null; | ||
getNextSibling(): QWElement | string | undefined | null; | ||
getAllPreviousSiblings(): Array<QWElement | string>; | ||
getAllNextSiblings(): Array<QWElement | string>; | ||
getPreviousSibling(): QWElement | string | null; | ||
getNextSibling(): QWElement | string | null; | ||
getElementParent(): QWElement | null; | ||
@@ -38,0 +40,0 @@ getParentAllContexts(): QWElement | null; |
@@ -259,2 +259,36 @@ "use strict"; | ||
} | ||
getAllPreviousSiblings() { | ||
const siblings = new Array(); | ||
let sibling = this.element.previousSibling; | ||
while (sibling !== null) { | ||
if (sibling.nodeType === 1) { | ||
const qwSibling = this.convertElementToQWElement(sibling); | ||
if (qwSibling) { | ||
siblings.unshift(qwSibling); | ||
} | ||
} | ||
else if (sibling.nodeType === 3 && sibling.textContent) { | ||
siblings.unshift(sibling.textContent); | ||
} | ||
sibling = sibling.previousSibling; | ||
} | ||
return siblings; | ||
} | ||
getAllNextSiblings() { | ||
const siblings = new Array(); | ||
let sibling = this.element.nextSibling; | ||
while (sibling !== null) { | ||
if (sibling.nodeType === 1) { | ||
const qwSibling = this.convertElementToQWElement(sibling); | ||
if (qwSibling) { | ||
siblings.unshift(qwSibling); | ||
} | ||
} | ||
else if (sibling.nodeType === 3 && sibling.textContent) { | ||
siblings.unshift(sibling.textContent); | ||
} | ||
sibling = sibling.nextSibling; | ||
} | ||
return siblings; | ||
} | ||
getPreviousSibling() { | ||
@@ -270,3 +304,15 @@ const sibling = this.element.previousSibling; | ||
else { | ||
return undefined; | ||
let siblingNode = sibling.previousSibling; | ||
let previousSibling = null; | ||
while (siblingNode !== null) { | ||
if (siblingNode.nodeType === 1) { | ||
previousSibling = this.convertElementToQWElement(siblingNode); | ||
break; | ||
} | ||
else if (siblingNode.nodeType === 3) { | ||
previousSibling = siblingNode.textContent; | ||
} | ||
siblingNode = siblingNode.previousSibling; | ||
} | ||
return previousSibling; | ||
} | ||
@@ -286,3 +332,15 @@ } | ||
else { | ||
return undefined; | ||
let siblingNode = sibling.nextSibling; | ||
let nextSibling = null; | ||
while (siblingNode !== null) { | ||
if (siblingNode.nodeType === 1) { | ||
nextSibling = this.convertElementToQWElement(siblingNode); | ||
break; | ||
} | ||
else if (siblingNode.nodeType === 3) { | ||
nextSibling = siblingNode.textContent; | ||
} | ||
siblingNode = siblingNode.nextSibling; | ||
} | ||
return nextSibling; | ||
} | ||
@@ -289,0 +347,0 @@ } |
{ | ||
"name": "@qualweb/qw-element", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "QualWeb element interface and utilities", | ||
@@ -37,7 +37,7 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@qualweb/types": "^0.6.10", | ||
"@qualweb/types": "^0.6.11", | ||
"@tsconfig/recommended": "^1.0.1", | ||
"@types/node": "^16.3.3", | ||
"@typescript-eslint/eslint-plugin": "^4.28.3", | ||
"@typescript-eslint/parser": "^4.28.3", | ||
"@typescript-eslint/eslint-plugin": "^4.28.4", | ||
"@typescript-eslint/parser": "^4.28.4", | ||
"chai": "^4.3.4", | ||
@@ -44,0 +44,0 @@ "eslint": "^7.31.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46941
637