@krautzource/aria-tree-walker
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -5,2 +5,9 @@ # Changelog | ||
### [3.0.1](https://github.com/krautzource/aria-tree-walker/compare/v3.0.0...v3.0.1) (2021-03-31) | ||
### Bug Fixes | ||
* **abstractTree:** querySelect from treebase ([90128a8](https://github.com/krautzource/aria-tree-walker/commit/90128a87fec1c6a0615ce012ead7285d8d953043)), closes [#33](https://github.com/krautzource/aria-tree-walker/issues/33) | ||
## [3.0.0](https://github.com/krautzource/aria-tree-walker/compare/v2.0.0...v3.0.0) (2021-03-21) | ||
@@ -7,0 +14,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=i=>{const s=new e(i.getAttribute("data-owns-id"));"A"===i.tagName.toUpperCase()&&""!==i.getAttribute("href")&&(s.href=i.getAttribute("href"),i.setAttribute("tabindex","-1"));const a=i.getAttribute("data-owns");return a?(a.split(" ").forEach((e=>{const i=document.querySelector(`[data-owns-id="${e}"]`),a=t(i);a.parent=s,s.children.push(a)})),s):s};class e{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class i{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}class s{constructor(e){this.node=e,this.tree=(e=>{const s=e.hasAttribute("data-owns")?e:e.querySelector("[data-owns]");return s?new i(t(s)):console.warn("no data-owns attribute in tree:",e)})(e),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}exports.attachNavigator=function(t){new s(t),t.setAttribute("tabindex","0")}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=(i,s)=>{const a=new e(s.getAttribute("data-owns-id"));"A"===s.tagName.toUpperCase()&&""!==s.getAttribute("href")&&(a.href=s.getAttribute("href"),s.setAttribute("tabindex","-1"));const n=s.getAttribute("data-owns");return n?(n.split(" ").forEach((e=>{const s=i.querySelector(`[data-owns-id="${e}"]`),n=t(i,s);n.parent=a,a.children.push(n)})),a):a};class e{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class i{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}class s{constructor(e){this.node=e,this.tree=(e=>{const s=e.hasAttribute("data-owns")?e:e.querySelector("[data-owns]");return s?new i(t(s,s)):console.warn("no data-owns attribute in tree:",e)})(e),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}exports.attachNavigator=function(t){new s(t),t.setAttribute("tabindex","0")}; |
@@ -1,1 +0,1 @@ | ||
const t=i=>{const s=new e(i.getAttribute("data-owns-id"));"A"===i.tagName.toUpperCase()&&""!==i.getAttribute("href")&&(s.href=i.getAttribute("href"),i.setAttribute("tabindex","-1"));const a=i.getAttribute("data-owns");return a?(a.split(" ").forEach((e=>{const i=document.querySelector(`[data-owns-id="${e}"]`),a=t(i);a.parent=s,s.children.push(a)})),s):s};class e{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class i{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}function s(t){new a(t),t.setAttribute("tabindex","0")}class a{constructor(e){this.node=e,this.tree=(e=>{const s=e.hasAttribute("data-owns")?e:e.querySelector("[data-owns]");return s?new i(t(s)):console.warn("no data-owns attribute in tree:",e)})(e),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}export{s as attachNavigator}; | ||
const t=(i,s)=>{const a=new e(s.getAttribute("data-owns-id"));"A"===s.tagName.toUpperCase()&&""!==s.getAttribute("href")&&(a.href=s.getAttribute("href"),s.setAttribute("tabindex","-1"));const n=s.getAttribute("data-owns");return n?(n.split(" ").forEach((e=>{const s=i.querySelector(`[data-owns-id="${e}"]`),n=t(i,s);n.parent=a,a.children.push(n)})),a):a};class e{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class i{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}function s(t){new a(t),t.setAttribute("tabindex","0")}class a{constructor(e){this.node=e,this.tree=(e=>{const s=e.hasAttribute("data-owns")?e:e.querySelector("[data-owns]");return s?new i(t(s,s)):console.warn("no data-owns attribute in tree:",e)})(e),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}export{s as attachNavigator}; |
@@ -1,1 +0,1 @@ | ||
var AriaTreeWalker=function(t){"use strict";const e=t=>{const s=new i(t.getAttribute("data-owns-id"));"A"===t.tagName.toUpperCase()&&""!==t.getAttribute("href")&&(s.href=t.getAttribute("href"),t.setAttribute("tabindex","-1"));const a=t.getAttribute("data-owns");return a?(a.split(" ").forEach((t=>{const i=document.querySelector(`[data-owns-id="${t}"]`),a=e(i);a.parent=s,s.children.push(a)})),s):s};class i{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class s{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}class a{constructor(t){this.node=t,this.tree=(t=>{const i=t.hasAttribute("data-owns")?t:t.querySelector("[data-owns]");return i?new s(e(i)):console.warn("no data-owns attribute in tree:",t)})(t),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}return t.attachNavigator=function(t){new a(t),t.setAttribute("tabindex","0")},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
var AriaTreeWalker=function(t){"use strict";const e=(t,s)=>{const a=new i(s.getAttribute("data-owns-id"));"A"===s.tagName.toUpperCase()&&""!==s.getAttribute("href")&&(a.href=s.getAttribute("href"),s.setAttribute("tabindex","-1"));const n=s.getAttribute("data-owns");return n?(n.split(" ").forEach((i=>{const s=t.querySelector(`[data-owns-id="${i}"]`),n=e(t,s);n.parent=a,a.children.push(n)})),a):a};class i{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class s{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}class a{constructor(t){this.node=t,this.tree=(t=>{const i=t.hasAttribute("data-owns")?t:t.querySelector("[data-owns]");return i?new s(e(i,i)):console.warn("no data-owns attribute in tree:",t)})(t),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}return t.attachNavigator=function(t){new a(t),t.setAttribute("tabindex","0")},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
@@ -17,7 +17,7 @@ const fs = require('fs'); | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>ARIA (owns) Tree walker</title> | ||
<title>ARIA Tree walker</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<h1>A lightweight walker for labeled aria(-owns) trees</h1> | ||
<h1>A lightweight walker for labeled ARIA trees</h1> | ||
<p>For development, this demo requires a browser with support for ES6 modules. Try current Firefox, e.g., with NVDA or JAWS.</p> | ||
@@ -24,0 +24,0 @@ <p><strong>Try this</strong>: focus a diagram (click on it or tab to it), then use the arrow keys. If you're using a screenreader, use browse mode until you encounter a diagram, then switch out of virtual/browse mode to explore with arrow keys. Depending on the screenreader you may have to move the focus to the diagram.</p> |
@@ -71,3 +71,3 @@ const sre = require('speech-rule-engine'); | ||
rewrite(svgnode); | ||
rewrite(svgnode.firstElementChild); | ||
@@ -74,0 +74,0 @@ const chtmlnode = chtmlhtml.convert(mmlpretty, { |
@@ -1,1 +0,1 @@ | ||
const t=i=>{const s=new e(i.getAttribute("data-owns-id"));"A"===i.tagName.toUpperCase()&&""!==i.getAttribute("href")&&(s.href=i.getAttribute("href"),i.setAttribute("tabindex","-1"));const a=i.getAttribute("data-owns");return a?(a.split(" ").forEach((e=>{const i=document.querySelector(`[data-owns-id="${e}"]`),a=t(i);a.parent=s,s.children.push(a)})),s):s};class e{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class i{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}function s(t){new a(t),t.setAttribute("tabindex","0")}class a{constructor(e){this.node=e,this.tree=(e=>{const s=e.hasAttribute("data-owns")?e:e.querySelector("[data-owns]");return s?new i(t(s)):console.warn("no data-owns attribute in tree:",e)})(e),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}export{s as attachNavigator}; | ||
const t=(i,s)=>{const a=new e(s.getAttribute("data-owns-id"));"A"===s.tagName.toUpperCase()&&""!==s.getAttribute("href")&&(a.href=s.getAttribute("href"),s.setAttribute("tabindex","-1"));const n=s.getAttribute("data-owns");return n?(n.split(" ").forEach((e=>{const s=i.querySelector(`[data-owns-id="${e}"]`),n=t(i,s);n.parent=a,a.children.push(n)})),a):a};class e{constructor(t){this.name=t,this.parent=null,this.href=null,this.children=[]}}class i{constructor(t){this.root=t,this.active=t}up(){this.active.parent&&(this.active=this.active.parent)}down(){this.active.children.length&&(this.active=this.active.children[0])}left(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t>0&&(this.active=this.active.parent.children[t-1])}}right(){if(this.active.parent){let t=this.active.parent.children.indexOf(this.active);t<this.active.parent.children.length-1&&(this.active=this.active.parent.children[t+1])}}activateLink(){this.active.href&&(window.location.href=this.active.href)}}function s(t){new a(t),t.setAttribute("tabindex","0")}class a{constructor(e){this.node=e,this.tree=(e=>{const s=e.hasAttribute("data-owns")?e:e.querySelector("[data-owns]");return s?new i(t(s,s)):console.warn("no data-owns attribute in tree:",e)})(e),this.node.addEventListener("keydown",this.move.bind(this)),this.node.addEventListener("focusin",(()=>{this.node.setAttribute("tabindex","-1"),this.highlight(!0)})),this.node.addEventListener("focusout",(()=>{this.highlight(!1),this.node.setAttribute("tabindex","0")}))}active(){return this.tree.active}move(t){switch(this.highlight(!1),[32,37,38,39,40,13,32].indexOf(t.keyCode)>-1&&t.preventDefault(),t.keyCode){case 37:this.tree.left();break;case 38:this.tree.up();break;case 39:this.tree.right();break;case 40:this.tree.down();break;case 32:case 13:this.tree.activateLink()}this.highlight(!0)}highlight(t){const e=this.active().name===this.node.getAttribute("data-owns-id")?this.node:this.node.querySelector(`[data-owns-id="${this.active().name}"]`);!0===t&&(e.setAttribute("tabindex","0"),e.classList.add("is-activedescendant"),e.focus()),!1===t&&(e.setAttribute("tabindex","-1"),e.classList.remove("is-activedescendant"))}}export{s as attachNavigator}; |
@@ -12,3 +12,3 @@ /** | ||
if (!treebase) return console.warn('no data-owns attribute in tree:', node); | ||
return new abstractTree(recurseNodeToExtractTree(treebase)); | ||
return new abstractTree(recurseNodeToExtractTree(treebase, treebase)); | ||
}; | ||
@@ -18,7 +18,8 @@ | ||
* Recurses through DOM node to create abstract tree. | ||
* @param {Node} node A node (with data-owns attribute). | ||
* @param {Node} treebase The root of the (data-owns) tree. | ||
* @param {Node} node An owned node of the treebase (with data-owns-id and possibly data-owns attribute). | ||
* @returns {abstractNode} An abstract tree node. | ||
*/ | ||
const recurseNodeToExtractTree = (node) => { | ||
const recurseNodeToExtractTree = (treebase, node) => { | ||
const parent = new abstractNode(node.getAttribute('data-owns-id')); | ||
@@ -34,4 +35,4 @@ if (node.tagName.toUpperCase() === 'A' && node.getAttribute('href') !== '') { | ||
owns.split(' ').forEach((id) => { | ||
const child = document.querySelector(`[data-owns-id="${id}"]`); | ||
const newnode = recurseNodeToExtractTree(child); | ||
const child = treebase.querySelector(`[data-owns-id="${id}"]`); | ||
const newnode = recurseNodeToExtractTree(treebase, child); | ||
newnode.parent = parent; | ||
@@ -38,0 +39,0 @@ parent.children.push(newnode); |
{ | ||
"name": "@krautzource/aria-tree-walker", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "A lightweight walker for labeled aria(-owns) trees", | ||
@@ -5,0 +5,0 @@ "main": "dist/aria-tree-walker.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
379735
1491