@asamuzakjp/dom-selector 6.2.0 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/js/constant.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var E=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var F=(o,t)=>{for(var n in t)E(o,n,{get:t[n],enumerable:!0})},M=(o,t,n,L)=>{if(t&&typeof t=="object"||typeof t=="function")for(let
|
|
1
|
+
var E=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var F=(o,t)=>{for(var n in t)E(o,n,{get:t[n],enumerable:!0})},M=(o,t,n,L)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of a(t))!i.call(o,r)&&r!==n&&E(o,r,{get:()=>t[r],enumerable:!(L=R(t,r))||L.enumerable});return o};var U=o=>M(E({},"__esModule",{value:!0}),o);var Gt={};F(Gt,{ALPHA_NUM:()=>I,ANB:()=>A,ATTR_SELECTOR:()=>b,BIT_01:()=>g,BIT_02:()=>Z,BIT_04:()=>v,BIT_08:()=>q,BIT_16:()=>J,BIT_32:()=>Q,BIT_FFFF:()=>V,CHILD_IDX:()=>C,CLASS_SELECTOR:()=>d,COMBINATOR:()=>G,COMBO:()=>T,COMPLEX:()=>_,COMPLEX_L:()=>S,COMPOUND:()=>c,COMPOUND_A:()=>O,COMPOUND_B:()=>N,COMPOUND_I:()=>Pt,DESCEND:()=>Dt,DIGIT:()=>x,DOCUMENT_FRAGMENT_NODE:()=>Et,DOCUMENT_NODE:()=>xt,DOCUMENT_POSITION_CONTAINED_BY:()=>_t,DOCUMENT_POSITION_CONTAINS:()=>Tt,DOCUMENT_POSITION_PRECEDING:()=>pt,DUO:()=>tt,ELEMENT_NODE:()=>ct,HEX:()=>ot,HYPHEN:()=>et,IDENT:()=>Y,ID_SELECTOR:()=>f,KEY_FORM_FOCUS:()=>at,KEY_INPUT_BUTTON:()=>it,KEY_INPUT_DATE:()=>P,KEY_INPUT_EDIT:()=>Ft,KEY_INPUT_LTR:()=>Mt,KEY_INPUT_TEXT:()=>$,KEY_LOGICAL:()=>Ut,KEY_MODIFIER:()=>bt,KEY_SHADOW_HOST:()=>dt,LANG_PART:()=>Ct,LOGICAL_COMPLEX:()=>$t,LOGICAL_COMPOUND:()=>Rt,NESTED_LOGICAL_A:()=>l,NESTED_LOGICAL_B:()=>D,NOT_SUPPORTED_ERR:()=>m,NTH:()=>B,N_TH:()=>lt,OPERATOR:()=>h,PSEUDO_CLASS:()=>At,PS_CLASS_SELECTOR:()=>H,PS_ELEMENT_SELECTOR:()=>u,SELECTOR:()=>y,SHOW_ALL:()=>Ot,SHOW_DOCUMENT:()=>Nt,SHOW_DOCUMENT_FRAGMENT:()=>St,SHOW_ELEMENT:()=>Lt,STRING:()=>z,SUB_TYPE:()=>s,SYNTAX_ERR:()=>K,TAG_TYPE:()=>e,TAG_TYPE_I:()=>p,TARGET_ALL:()=>j,TARGET_FIRST:()=>k,TARGET_LINEAL:()=>X,TARGET_SELF:()=>w,TEXT_NODE:()=>nt,TYPE_FROM:()=>rt,TYPE_SELECTOR:()=>W,TYPE_TO:()=>st,WALKER_FILTER:()=>It});module.exports=U(Gt);const b="AttributeSelector",d="ClassSelector",G="Combinator",Y="Identifier",f="IdSelector",m="NotSupportedError",B="Nth",h="Operator",H="PseudoClassSelector",u="PseudoElementSelector",y="Selector",z="String",K="SyntaxError",j="all",k="first",X="lineal",w="self",W="TypeSelector",g=1,Z=2,v=4,q=8,J=16,Q=32,V=65535,tt=2,ot=16,et=45,rt=8,st=-1,ct=1,nt=3,xt=9,Et=11,pt=2,Tt=8,_t=16,Ot=4294967295,Nt=256,St=1024,Lt=1,It=1281,I="[A-Z\\d]+",C="(?:first|last|only)-(?:child|of-type)",x="(?:0|[1-9]\\d*)",Ct=`(?:-${I})*`,At=`(?:any-)?link|${C}|checked|empty|indeterminate|read-(?:only|write)|root|target`,A=`[+-]?(?:${x}n?|n)|(?:[+-]?${x})?n\\s*[+-]\\s*${x}`,lt=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${A})\\s*\\)`,s="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",p="\\*|[A-Z][\\w-]*",c=`(?:${e}|(?:${e})?(?:${s})+)`,T="\\s?[\\s>~+]\\s?",_=`${c}(?:${T}${c})*`,Dt="\\s?[\\s>]\\s?",l=`:is\\(\\s*${c}(?:\\s*,\\s*${c})*\\s*\\)`,D=`:is\\(\\s*${_}(?:\\s*,\\s*${_})*\\s*\\)`,O=`(?:${e}|(?:${e})?(?:${s}|${l})+)`,N=`(?:${e}|(?:${e})?(?:${s}|${D})+)`,Pt=`(?:${p}|(?:${p})?(?:${s})+)`,S=`${N}(?:${T}${N})*`,$t=`(?:is|not)\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,Rt=`(?:is|not)\\(\\s*${O}(?:\\s*,\\s*${O})*\\s*\\)`,at=Object.freeze(["button","input","select","textarea"]),it=Object.freeze(["button","reset","submit"]),P=Object.freeze(["date","datetime-local","month","time","week"]),$=Object.freeze(["email","password","search","tel","text","url"]),Ft=Object.freeze([...P,...$,"number"]),Mt=Object.freeze(["checkbox","color","date","image","number","range","radio","time"]),Ut=Object.freeze(["has","is","not","where"]),bt=Object.freeze(["Alt","AltGraph","CapsLock","Control","Fn","FnLock","Hyper","Meta","NumLock","ScrollLock","Shift","Super","Symbol","SymbolLock"]),dt=Object.freeze(["host","host-context"]);0&&(module.exports={ALPHA_NUM,ANB,ATTR_SELECTOR,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,CHILD_IDX,CLASS_SELECTOR,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DESCEND,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,HEX,HYPHEN,IDENT,ID_SELECTOR,KEY_FORM_FOCUS,KEY_INPUT_BUTTON,KEY_INPUT_DATE,KEY_INPUT_EDIT,KEY_INPUT_LTR,KEY_INPUT_TEXT,KEY_LOGICAL,KEY_MODIFIER,KEY_SHADOW_HOST,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,OPERATOR,PSEUDO_CLASS,PS_CLASS_SELECTOR,PS_ELEMENT_SELECTOR,SELECTOR,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_SELECTOR,TYPE_TO,WALKER_FILTER});
|
|
2
2
|
//# sourceMappingURL=constant.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/js/constant.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const ATTR_SELECTOR = 'AttributeSelector';\nexport const CLASS_SELECTOR = 'ClassSelector';\nexport const COMBINATOR = 'Combinator';\nexport const IDENT = 'Identifier';\nexport const ID_SELECTOR = 'IdSelector';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const OPERATOR = 'Operator';\nexport const PS_CLASS_SELECTOR = 'PseudoClassSelector';\nexport const PS_ELEMENT_SELECTOR = 'PseudoElementSelector';\nexport const SELECTOR = 'Selector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const TARGET_ALL = 'all';\nexport const TARGET_FIRST = 'first';\nexport const TARGET_LINEAL = 'lineal';\nexport const TARGET_SELF = 'self';\nexport const TYPE_SELECTOR = 'TypeSelector';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const HYPHEN = 0x2D;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xFFFFFFFF;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* selectors */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)';\nexport const DIGIT = '(?:0|[1-9]\\\\d*)';\nexport const LANG_PART = `(?:-${ALPHA_NUM})*`;\nexport const PSEUDO_CLASS
|
|
5
|
-
"mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,QAAAC,EAAA,kBAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,mBAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,aAAAC,EA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GAAgB,EAChBD,GAAyB,GACzBI,GAA8B,EAC9BD,GAA6B,EAC7BD,GAAiC,GAGjC+B,GAAW,WACXC,GAAgB,IAChBC,GAAyB,KACzBC,GAAe,EACfc,GAAgB,KAGhBxE,EAAY,YACZU,EAAY,wCACZW,EAAQ,kBACRqB,GAAY,OAAO1C,CAAS,KAC5BmD,
|
|
4
|
+
"sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const ATTR_SELECTOR = 'AttributeSelector';\nexport const CLASS_SELECTOR = 'ClassSelector';\nexport const COMBINATOR = 'Combinator';\nexport const IDENT = 'Identifier';\nexport const ID_SELECTOR = 'IdSelector';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const OPERATOR = 'Operator';\nexport const PS_CLASS_SELECTOR = 'PseudoClassSelector';\nexport const PS_ELEMENT_SELECTOR = 'PseudoElementSelector';\nexport const SELECTOR = 'Selector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const TARGET_ALL = 'all';\nexport const TARGET_FIRST = 'first';\nexport const TARGET_LINEAL = 'lineal';\nexport const TARGET_SELF = 'self';\nexport const TYPE_SELECTOR = 'TypeSelector';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const HYPHEN = 0x2D;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xFFFFFFFF;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* selectors */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)';\nexport const DIGIT = '(?:0|[1-9]\\\\d*)';\nexport const LANG_PART = `(?:-${ALPHA_NUM})*`;\nexport const PSEUDO_CLASS = `(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|read-(?:only|write)|root|target`;\nexport const ANB =\n `[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\\\s*[+-]\\\\s*${DIGIT}`;\n// N_TH: excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo)\nexport const N_TH =\n `nth-(?:last-)?(?:child|of-type)\\\\(\\\\s*(?:even|odd|${ANB})\\\\s*\\\\)`;\n// SUB_TYPE: attr, id, class, pseudo-class, note that [foo|=bar] is excluded\nexport const SUB_TYPE = '\\\\[[^|\\\\]]+\\\\]|[#.:][\\\\w-]+';\n// TAG_TYPE: *, tag\nexport const TAG_TYPE = '\\\\*|[A-Za-z][\\\\w-]*';\nexport const TAG_TYPE_I = '\\\\*|[A-Z][\\\\w-]*';\nexport const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`;\nexport const COMBO = '\\\\s?[\\\\s>~+]\\\\s?';\nexport const COMPLEX = `${COMPOUND}(?:${COMBO}${COMPOUND})*`;\nexport const DESCEND = '\\\\s?[\\\\s>]\\\\s?';\nexport const NESTED_LOGICAL_A =\n `:is\\\\(\\\\s*${COMPOUND}(?:\\\\s*,\\\\s*${COMPOUND})*\\\\s*\\\\)`;\nexport const NESTED_LOGICAL_B =\n `:is\\\\(\\\\s*${COMPLEX}(?:\\\\s*,\\\\s*${COMPLEX})*\\\\s*\\\\)`;\nexport const COMPOUND_A =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`;\nexport const COMPOUND_B =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`;\nexport const COMPOUND_I =\n `(?:${TAG_TYPE_I}|(?:${TAG_TYPE_I})?(?:${SUB_TYPE})+)`;\nexport const COMPLEX_L = `${COMPOUND_B}(?:${COMBO}${COMPOUND_B})*`;\nexport const LOGICAL_COMPLEX =\n `(?:is|not)\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `(?:is|not)\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* array */\nexport const KEY_FORM_FOCUS =\n Object.freeze(['button', 'input', 'select', 'textarea']);\nexport const KEY_INPUT_BUTTON = Object.freeze(['button', 'reset', 'submit']);\nexport const KEY_INPUT_DATE =\n Object.freeze(['date', 'datetime-local', 'month', 'time', 'week']);\nexport const KEY_INPUT_TEXT =\n Object.freeze(['email', 'password', 'search', 'tel', 'text', 'url']);\nexport const KEY_INPUT_EDIT =\n Object.freeze([...KEY_INPUT_DATE, ...KEY_INPUT_TEXT, 'number']);\nexport const KEY_INPUT_LTR = Object.freeze([\n 'checkbox', 'color', 'date', 'image', 'number', 'range', 'radio', 'time'\n]);\nexport const KEY_LOGICAL = Object.freeze(['has', 'is', 'not', 'where']);\nexport const KEY_MODIFIER = Object.freeze([\n 'Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'FnLock', 'Hyper', 'Meta',\n 'NumLock', 'ScrollLock', 'Shift', 'Super', 'Symbol', 'SymbolLock'\n]);\nexport const KEY_SHADOW_HOST = Object.freeze(['host', 'host-context']);\n"],
|
|
5
|
+
"mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAA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AAmB,OAAO,OAAO,CAAC,SAAU,QAAS,QAAQ,CAAC,EAC9DC,EACX,OAAO,OAAO,CAAC,OAAQ,iBAAkB,QAAS,OAAQ,MAAM,CAAC,EACtDG,EACX,OAAO,OAAO,CAAC,QAAS,WAAY,SAAU,MAAO,OAAQ,KAAK,CAAC,EACxDF,GACX,OAAO,OAAO,CAAC,GAAGD,EAAgB,GAAGG,EAAgB,QAAQ,CAAC,EACnDD,GAAgB,OAAO,OAAO,CACzC,WAAY,QAAS,OAAQ,QAAS,SAAU,QAAS,QAAS,MACpE,CAAC,EACYE,GAAc,OAAO,OAAO,CAAC,MAAO,KAAM,MAAO,OAAO,CAAC,EACzDC,GAAe,OAAO,OAAO,CACxC,MAAO,WAAY,WAAY,UAAW,KAAM,SAAU,QAAS,OACnE,UAAW,aAAc,QAAS,QAAS,SAAU,YACvD,CAAC,EACYC,GAAkB,OAAO,OAAO,CAAC,OAAQ,cAAc,CAAC",
|
|
6
6
|
"names": ["constant_exports", "__export", "ALPHA_NUM", "ANB", "ATTR_SELECTOR", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "CHILD_IDX", "CLASS_SELECTOR", "COMBINATOR", "COMBO", "COMPLEX", "COMPLEX_L", "COMPOUND", "COMPOUND_A", "COMPOUND_B", "COMPOUND_I", "DESCEND", "DIGIT", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "HEX", "HYPHEN", "IDENT", "ID_SELECTOR", "KEY_FORM_FOCUS", "KEY_INPUT_BUTTON", "KEY_INPUT_DATE", "KEY_INPUT_EDIT", "KEY_INPUT_LTR", "KEY_INPUT_TEXT", "KEY_LOGICAL", "KEY_MODIFIER", "KEY_SHADOW_HOST", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "OPERATOR", "PSEUDO_CLASS", "PS_CLASS_SELECTOR", "PS_ELEMENT_SELECTOR", "SELECTOR", "SHOW_ALL", "SHOW_DOCUMENT", "SHOW_DOCUMENT_FRAGMENT", "SHOW_ELEMENT", "STRING", "SUB_TYPE", "SYNTAX_ERR", "TAG_TYPE", "TAG_TYPE_I", "TARGET_ALL", "TARGET_FIRST", "TARGET_LINEAL", "TARGET_SELF", "TEXT_NODE", "TYPE_FROM", "TYPE_SELECTOR", "TYPE_TO", "WALKER_FILTER", "__toCommonJS"]
|
|
7
7
|
}
|
package/dist/cjs/js/utility.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var C=Object.create;var p=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,
|
|
1
|
+
var C=Object.create;var p=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var k=(e,r)=>{for(var t in r)p(e,t,{get:r[t],enumerable:!0})},E=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of U(r))!I.call(e,l)&&l!==t&&p(e,l,{get:()=>r[l],enumerable:!(i=D(r,l))||i.enumerable});return e};var d=(e,r,t)=>(t=e!=null?C(_(e)):{},E(r||!e||!e.__esModule?p(t,"default",{value:e,enumerable:!0}):t,e)),$=e=>E(p({},"__esModule",{value:!0}),e);var j={};k(j,{filterSelector:()=>W,getDirectionality:()=>T,getNamespaceURI:()=>g,getSlottedTextContent:()=>y,getType:()=>u,initNwsapi:()=>X,isContentEditable:()=>m,isCustomElement:()=>S,isFocusVisible:()=>G,isFocusable:()=>V,isFocusableArea:()=>F,isNamespaceDeclared:()=>K,isPreceding:()=>O,isVisible:()=>v,resolveContent:()=>M,sortNodes:()=>Y,traverseNode:()=>P});module.exports=$(j);var w=d(require("@asamuzakjp/nwsapi"),1),h=d(require("bidi-js"),1),b=d(require("is-potential-custom-element-name"),1),s=require("./constant.js");const A=new RegExp(`:(?!${s.PSEUDO_CLASS}|${s.N_TH}|${s.LOGICAL_COMPLEX})`),L=new RegExp(`:(?!${s.PSEUDO_CLASS}|${s.N_TH}|${s.LOGICAL_COMPOUND})`),R=new RegExp(`:(?!${s.PSEUDO_CLASS}|${s.N_TH})`),u=e=>Object.prototype.toString.call(e).slice(s.TYPE_FROM,s.TYPE_TO),M=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${u(e)}`);let r,t,i;switch(e.nodeType){case s.DOCUMENT_NODE:{r=e,t=e;break}case s.DOCUMENT_FRAGMENT_NODE:{const{host:n,mode:a,ownerDocument:o}=e;r=o,t=e,i=n&&(a==="close"||a==="open");break}case s.ELEMENT_NODE:{r=e.ownerDocument;let n=e;for(;n;){const{host:a,mode:o,nodeType:f,parentNode:c}=n;if(f===s.DOCUMENT_FRAGMENT_NODE){i=a&&(o==="close"||o==="open");break}else if(c)n=c;else break}t=n;break}default:throw new TypeError(`Unexpected node ${e.nodeName}`)}const l=r.createTreeWalker(t,s.WALKER_FILTER);return[r,t,l,!!i]},P=(e,r)=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${u(e)}`);if(!r)return null;let t=r.currentNode;if(t===e)return t;if(t.contains(e)){for(t=r.nextNode();t&&t!==e;)t=r.nextNode();return t}else{if(t!==r.root){let i;for(;t;){if(t===e){i=!0;break}else if(t===r.root)break;t=r.parentNode()}if(i)return t}if(e.nodeType===s.ELEMENT_NODE){let i;for(;t;){if(t===e){i=!0;break}t=r.nextNode()}if(i)return t}}return null},S=(e,r={})=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${u(e)}`);if(e.nodeType!==s.ELEMENT_NODE)return!1;const{localName:t,ownerDocument:i}=e,{formAssociated:l}=r,n=i.defaultView;let a;const o=e.getAttribute("is");return o?a=(0,b.default)(o)&&n.customElements.get(o):a=(0,b.default)(t)&&n.customElements.get(t),a?l?!!a.formAssociated:!0:!1},y=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${u(e)}`);if(typeof e.assignedNodes!="function")return null;const r=e.assignedNodes();if(r.length){let t;for(const i of r)if(t=i.textContent.trim(),t)break;return t}return e.textContent.trim()},T=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${u(e)}`);if(e.nodeType!==s.ELEMENT_NODE)return null;const{dir:r,localName:t,parentNode:i}=e,{getEmbeddingLevels:l}=(0,h.default)();if(r==="ltr"||r==="rtl")return r;if(r==="auto"){let n;switch(t){case"input":{const a=[...s.KEY_INPUT_BUTTON,...s.KEY_INPUT_TEXT,"hidden"];if(!e.type||a.includes(e.type))n=e.value;else if(["checkbox","color","date","image","number","range","radio","time"].includes(e.type))return"ltr";break}case"slot":{n=y(e);break}case"textarea":{n=e.value;break}default:{const a=[].slice.call(e.childNodes);for(const o of a){const{dir:f,localName:c,nodeType:N,textContent:x}=o;if(N===s.TEXT_NODE?n=x.trim():N===s.ELEMENT_NODE&&!["bdi","script","style","textarea"].includes(c)&&(!f||f!=="ltr"&&f!=="rtl")&&(c==="slot"?n=y(o):n=x.trim()),n)break}}}if(n){const{paragraphs:[{level:a}]}=l(n);if(a%2===1)return"rtl"}else if(i){const{nodeType:a}=i;if(a===s.ELEMENT_NODE)return T(i)}}else{if(t==="input"&&e.type==="tel")return"ltr";if(t==="bdi"){const n=e.textContent.trim();if(n){const{paragraphs:[{level:a}]}=l(n);if(a%2===1)return"rtl"}}else if(i){if(t==="slot"){const a=y(e);if(a){const{paragraphs:[{level:o}]}=l(a);return o%2===1?"rtl":"ltr"}}const{nodeType:n}=i;if(n===s.ELEMENT_NODE)return T(i)}}return"ltr"},m=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${u(e)}`);if(e.nodeType!==s.ELEMENT_NODE)return!1;if(typeof e.isContentEditable=="boolean")return e.isContentEditable;if(e.ownerDocument.designMode==="on")return!0;{let r;switch(e.hasAttribute("contenteditable")?r=e.getAttribute("contenteditable"):r="inherit",r){case"":case"true":return!0;case"plaintext-only":return!0;case"false":return!1;default:return e?.parentNode?.nodeType===s.ELEMENT_NODE?m(e.parentNode):!1}}},v=e=>{if(e?.nodeType!==s.ELEMENT_NODE)return!1;const r=e.ownerDocument.defaultView,{display:t,visibility:i}=r.getComputedStyle(e);return t!=="none"&&i==="visible"},G=e=>{if(e?.nodeType!==s.ELEMENT_NODE)return!1;const{localName:r,type:t}=e;switch(r){case"input":return!!(!t||s.KEY_INPUT_EDIT.includes(t));case"textarea":return!0;default:return m(e)}},F=e=>{if(e?.nodeType!==s.ELEMENT_NODE||!e.isConnected)return!1;const r=e.ownerDocument.defaultView;if(e instanceof r.HTMLElement){if(Number.isInteger(parseInt(e.getAttribute("tabindex")))||m(e))return!0;const{localName:t,parentNode:i}=e;switch(t){case"a":return!!(e.href||e.hasAttribute("href"));case"iframe":return!0;case"input":return!(e.disabled||e.hasAttribute("disabled")||e.hidden||e.hasAttribute("hidden"));case"summary":{if(i.localName==="details"){let l=i.firstElementChild,n=!1;for(;l;){if(l.localName==="summary"){n=l===e;break}l=l.nextElementSibling}return n}return!1}default:if(["button","select","textarea"].includes(t)&&!(e.disabled||e.hasAttribute("disabled")))return!0}}else if(e instanceof r.SVGElement){if(Number.isInteger(parseInt(e.getAttributeNS(null,"tabindex")))){const t=["clipPath","defs","desc","linearGradient","marker","mask","metadata","pattern","radialGradient","script","style","symbol","title"],i="http://www.w3.org/2000/svg";let l,n=e;for(;n.namespaceURI===i&&(l=t.includes(n.localName),!l);)if(n?.parentNode?.namespaceURI===i)n=n.parentNode;else break;return!l}if(e.localName==="a"&&(e.href||e.hasAttributeNS(null,"href")))return!0}return!1},V=e=>{if(e?.nodeType!==s.ELEMENT_NODE)return!1;const r=e.ownerDocument.defaultView;let t=e,i=!0;for(;t;){if(t.disabled||t.hasAttribute("disabled")){i=!1;break}(t.hidden||t.hasAttribute("hidden"))&&(i=!1);const{contentVisibility:l,display:n,visibility:a}=r.getComputedStyle(t);if(n==="none"||a!=="visible"||l==="hidden"&&t!==e?i=!1:i=!0,i&&t?.parentNode?.nodeType===s.ELEMENT_NODE)t=t.parentNode;else break}return i},g=(e,r)=>{if(typeof e!="string")throw new TypeError(`Unexpected type ${u(e)}`);if(!r?.nodeType)throw new TypeError(`Unexpected type ${u(r)}`);if(!e||r.nodeType!==s.ELEMENT_NODE)return null;const{attributes:t}=r;let i;for(const l of t){const{name:n,namespaceURI:a,prefix:o,value:f}=l;if(n===`xmlns:${e}`?i=f:o===e&&(i=a),i)break}return i??null},K=(e="",r={})=>{if(!e||typeof e!="string"||r?.nodeType!==s.ELEMENT_NODE)return!1;if(r.lookupNamespaceURI(e))return!0;const t=r.ownerDocument.documentElement;let i=r,l;for(;i&&(l=g(e,i),!(l||i===t));)i=i.parentNode;return!!l},O=(e,r)=>{if(e?.nodeType){if(!r?.nodeType)throw new TypeError(`Unexpected type ${u(r)}`)}else throw new TypeError(`Unexpected type ${u(e)}`);if(e.nodeType!==s.ELEMENT_NODE||r.nodeType!==s.ELEMENT_NODE)return!1;const t=r.compareDocumentPosition(e);return!!(t&s.DOCUMENT_POSITION_PRECEDING||t&s.DOCUMENT_POSITION_CONTAINS)},Y=(e=[])=>{const r=[...e];return r.length>1&&r.sort((t,i)=>{let l;return O(i,t)?l=1:l=-1,l}),r},X=(e,r)=>{if(!e?.DOMException)throw new TypeError(`Unexpected global object ${u(e)}`);r?.nodeType!==s.DOCUMENT_NODE&&(r=e.document);const t=(0,w.default)({document:r,DOMException:e.DOMException});return t.configure({LOGERRORS:!1}),t},W=(e,r={})=>{if(!e||typeof e!="string")return!1;if(e.includes("[")){const t=e.lastIndexOf("[");if(e.substring(t).indexOf("]")<0)return!1}if(/[|\\]|::|[^\u0021-\u007F\s]|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]|:(?:is|where)\(\s*\)/.test(e))return!1;if(e.includes(":")){const{complex:t,descend:i}=r;return/:(?:is|not)\(/.test(e)?t?!A.test(e):!L.test(e):i?!1:!R.test(e)}return!0};0&&(module.exports={filterSelector,getDirectionality,getNamespaceURI,getSlottedTextContent,getType,initNwsapi,isContentEditable,isCustomElement,isFocusVisible,isFocusable,isFocusableArea,isNamespaceDeclared,isPreceding,isVisible,resolveContent,sortNodes,traverseNode});
|
|
2
2
|
//# sourceMappingURL=utility.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/js/utility.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * utility.js\n */\n\n/* import */\nimport nwsapi from '@asamuzakjp/nwsapi';\nimport bidiFactory from 'bidi-js';\nimport isCustomElementName from 'is-potential-custom-element-name';\n\n/* constants */\nimport {\n DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINS,\n DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, KEY_INPUT_BUTTON, KEY_INPUT_EDIT,\n KEY_INPUT_TEXT, LOGICAL_COMPLEX, LOGICAL_COMPOUND, N_TH, PSEUDO_CLASS,\n TEXT_NODE, TYPE_FROM, TYPE_TO, WALKER_FILTER\n} from './constant.js';\nconst REG_LOGICAL_COMPLEX =\n new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH}|${LOGICAL_COMPLEX})`);\nconst REG_LOGICAL_COMPOUND =\n new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH}|${LOGICAL_COMPOUND})`);\nconst REG_WO_LOGICAL = new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH})`);\n\n/**\n * get type\n * @param {*} o - object to check\n * @returns {string} - type of object\n */\nexport const getType = o =>\n Object.prototype.toString.call(o).slice(TYPE_FROM, TYPE_TO);\n\n/**\n * resolve content document, root node and tree walker, is in shadow\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {Array.<object|boolean>}\n * - array of document, root node , tree walker, node is in shadow\n */\nexport const resolveContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let document;\n let root;\n let shadow;\n switch (node.nodeType) {\n case DOCUMENT_NODE: {\n document = node;\n root = node;\n break;\n }\n case DOCUMENT_FRAGMENT_NODE: {\n const { host, mode, ownerDocument } = node;\n document = ownerDocument;\n root = node;\n shadow = host && (mode === 'close' || mode === 'open');\n break;\n }\n case ELEMENT_NODE: {\n document = node.ownerDocument;\n let refNode = node;\n while (refNode) {\n const { host, mode, nodeType, parentNode } = refNode;\n if (nodeType === DOCUMENT_FRAGMENT_NODE) {\n shadow = host && (mode === 'close' || mode === 'open');\n break;\n } else if (parentNode) {\n refNode = parentNode;\n } else {\n break;\n }\n }\n root = refNode;\n break;\n }\n default : {\n throw new TypeError(`Unexpected node ${node.nodeName}`);\n }\n }\n const walker = document.createTreeWalker(root, WALKER_FILTER);\n return [\n document,\n root,\n walker,\n !!shadow\n ];\n};\n\n/**\n * traverse node tree\n * @param {object} node - node\n * @param {object} walker - tree walker\n * @returns {?object} - current node\n */\nexport const traverseNode = (node, walker) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (!walker) {\n return null;\n }\n let refNode = walker.currentNode;\n if (refNode === node) {\n return refNode;\n } else if (refNode.contains(node)) {\n refNode = walker.nextNode();\n while (refNode) {\n if (refNode === node) {\n break;\n }\n refNode = walker.nextNode();\n }\n return refNode;\n } else {\n if (refNode !== walker.root) {\n let bool;\n while (refNode) {\n if (refNode === node) {\n bool = true;\n break;\n } else if (refNode === walker.root) {\n break;\n }\n refNode = walker.parentNode();\n }\n if (bool) {\n return refNode;\n }\n }\n if (node.nodeType === ELEMENT_NODE) {\n let bool;\n while (refNode) {\n if (refNode === node) {\n bool = true;\n break;\n }\n refNode = walker.nextNode();\n }\n if (bool) {\n return refNode;\n }\n }\n }\n return null;\n};\n\n/**\n * is custom element\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - result;\n */\nexport const isCustomElement = (node, opt = {}) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (node.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const { localName, ownerDocument } = node;\n const { formAssociated } = opt;\n const window = ownerDocument.defaultView;\n let elmConstructor;\n const attr = node.getAttribute('is');\n if (attr) {\n elmConstructor =\n isCustomElementName(attr) && window.customElements.get(attr);\n } else {\n elmConstructor =\n isCustomElementName(localName) && window.customElements.get(localName);\n }\n if (elmConstructor) {\n if (formAssociated) {\n return !!elmConstructor.formAssociated;\n }\n return true;\n }\n return false;\n};\n\n/**\n * get slotted text content\n * @param {object} node - Element node\n * @returns {?string} - text content\n */\nexport const getSlottedTextContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (typeof node.assignedNodes !== 'function') {\n return null;\n }\n const nodes = node.assignedNodes();\n if (nodes.length) {\n let text;\n for (const item of nodes) {\n text = item.textContent.trim();\n if (text) {\n break;\n }\n }\n return text;\n }\n return node.textContent.trim();\n};\n\n/**\n * get directionality of node\n * @see https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute\n * @param {object} node - Element node\n * @returns {?string} - 'ltr' / 'rtl'\n */\nexport const getDirectionality = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (node.nodeType !== ELEMENT_NODE) {\n return null;\n }\n const { dir: dirAttr, localName, parentNode } = node;\n const { getEmbeddingLevels } = bidiFactory();\n if (dirAttr === 'ltr' || dirAttr === 'rtl') {\n return dirAttr;\n } else if (dirAttr === 'auto') {\n let text;\n switch (localName) {\n case 'input': {\n const valueKeys = [...KEY_INPUT_BUTTON, ...KEY_INPUT_TEXT, 'hidden'];\n if (!node.type || valueKeys.includes(node.type)) {\n text = node.value;\n } else {\n const ltrKeys = [\n 'checkbox', 'color', 'date', 'image', 'number', 'range', 'radio',\n 'time'\n ];\n if (ltrKeys.includes(node.type)) {\n return 'ltr';\n }\n }\n break;\n }\n case 'slot': {\n text = getSlottedTextContent(node);\n break;\n }\n case 'textarea': {\n text = node.value;\n break;\n }\n default: {\n const items = [].slice.call(node.childNodes);\n for (const item of items) {\n const {\n dir: itemDir, localName: itemLocalName, nodeType: itemNodeType,\n textContent: itemTextContent\n } = item;\n if (itemNodeType === TEXT_NODE) {\n text = itemTextContent.trim();\n } else if (itemNodeType === ELEMENT_NODE) {\n const keys = ['bdi', 'script', 'style', 'textarea'];\n if (!keys.includes(itemLocalName) &&\n (!itemDir || (itemDir !== 'ltr' && itemDir !== 'rtl'))) {\n if (itemLocalName === 'slot') {\n text = getSlottedTextContent(item);\n } else {\n text = itemTextContent.trim();\n }\n }\n }\n if (text) {\n break;\n }\n }\n }\n }\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n return 'rtl';\n }\n } else if (parentNode) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n return getDirectionality(parentNode);\n }\n }\n } else if (localName === 'input' && node.type === 'tel') {\n return 'ltr';\n } else if (localName === 'bdi') {\n const text = node.textContent.trim();\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n return 'rtl';\n }\n }\n } else if (parentNode) {\n if (localName === 'slot') {\n const text = getSlottedTextContent(node);\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n return 'rtl';\n }\n return 'ltr';\n }\n }\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n return getDirectionality(parentNode);\n }\n }\n return 'ltr';\n};\n\n/**\n * is content editable\n * NOTE: not implemented in jsdom https://github.com/jsdom/jsdom/issues/1670\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isContentEditable = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (node.nodeType !== ELEMENT_NODE) {\n return false;\n }\n if (typeof node.isContentEditable === 'boolean') {\n return node.isContentEditable;\n } else if (node.ownerDocument.designMode === 'on') {\n return true;\n } else if (node.hasAttribute('contenteditable')) {\n const attr = node.getAttribute('contenteditable');\n switch (attr) {\n case '':\n case 'true': {\n return true;\n }\n case 'plaintext-only': {\n // FIXME: the element's raw text is editable,\n // but rich text formatting is disabled\n return true;\n }\n case 'false': {\n return false;\n }\n default: {\n let parent = node.parentNode;\n let bool = false;\n while (parent) {\n if (isContentEditable(parent)) {\n bool = true;\n break;\n }\n parent = parent.parentNode;\n }\n return bool;\n }\n }\n }\n return false;\n};\n\n/**\n * is node visible\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isVisible = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const window = node.ownerDocument.defaultView;\n const { display, visibility } = window.getComputedStyle(node);\n if (display !== 'none' && visibility === 'visible') {\n return true;\n }\n return false;\n};\n\n/**\n * is focus visible\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusVisible = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const { localName, type } = node;\n switch (localName) {\n case 'input': {\n if (!type || KEY_INPUT_EDIT.includes(type)) {\n return true;\n }\n return false;\n }\n case 'textarea': {\n return true;\n }\n default: {\n return isContentEditable(node);\n }\n }\n};\n\n/**\n * is focusable area\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusableArea = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n if (!node.isConnected) {\n return false;\n }\n const window = node.ownerDocument.defaultView;\n if (node instanceof window.HTMLElement) {\n if (Number.isInteger(parseInt(node.getAttribute('tabindex')))) {\n return true;\n }\n if (isContentEditable(node)) {\n return true;\n }\n const { localName, parentNode } = node;\n switch (localName) {\n case 'a': {\n if (node.href || node.hasAttribute('href')) {\n return true;\n }\n return false;\n }\n case 'iframe': {\n return true;\n }\n case 'input': {\n if (node.disabled || node.hasAttribute('disabled') ||\n node.hidden || node.hasAttribute('hidden')) {\n return false;\n }\n return true;\n }\n case 'summary': {\n if (parentNode.localName === 'details') {\n let child = parentNode.firstElementChild;\n let bool = false;\n while (child) {\n if (child.localName === 'summary') {\n bool = child === node;\n break;\n }\n child = child.nextElementSibling;\n }\n return bool;\n }\n return false;\n }\n default: {\n const keys = ['button', 'select', 'textarea'];\n if (keys.includes(localName) &&\n !(node.disabled || node.hasAttribute('disabled'))) {\n return true;\n }\n }\n }\n } else if (node instanceof window.SVGElement) {\n if (Number.isInteger(parseInt(node.getAttributeNS(null, 'tabindex')))) {\n const keys = [\n 'clipPath', 'defs', 'desc', 'linearGradient', 'marker', 'mask',\n 'metadata', 'pattern', 'radialGradient', 'script', 'style', 'symbol',\n 'title'\n ];\n const ns = 'http://www.w3.org/2000/svg';\n let bool;\n let refNode = node;\n while (refNode.namespaceURI === ns) {\n bool = keys.includes(refNode.localName);\n if (bool) {\n break;\n }\n if (refNode?.parentNode?.namespaceURI === ns) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n if (bool) {\n return false;\n }\n return true;\n }\n if (node.localName === 'a' &&\n (node.href || node.hasAttributeNS(null, 'href'))) {\n return true;\n }\n }\n return false;\n};\n\n/**\n * is focusable\n * NOTE: not applied, need fix in jsdom itself\n * @see https://github.com/whatwg/html/pull/8392\n * @see https://phabricator.services.mozilla.com/D156219\n * @see https://github.com/jsdom/jsdom/issues/3029\n * @see https://github.com/jsdom/jsdom/issues/3464\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusable = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const window = node.ownerDocument.defaultView;\n let refNode = node;\n let res = true;\n while (refNode) {\n if (refNode.disabled || refNode.hasAttribute('disabled')) {\n res = false;\n break;\n }\n if (refNode.hidden || refNode.hasAttribute('hidden')) {\n res = false;\n }\n const {\n contentVisibility, display, visibility\n } = window.getComputedStyle(refNode);\n if (display === 'none' || visibility !== 'visible' ||\n (contentVisibility === 'hidden' && refNode !== node)) {\n res = false;\n } else {\n res = true;\n }\n if (res && refNode?.parentNode?.nodeType === ELEMENT_NODE) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n return res;\n};\n\n/**\n * get namespace URI\n * @param {string} ns - namespace prefix\n * @param {Array} node - Element node\n * @returns {?string} - namespace URI\n */\nexport const getNamespaceURI = (ns, node) => {\n if (typeof ns !== 'string') {\n throw new TypeError(`Unexpected type ${getType(ns)}`);\n } else if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (!ns || node.nodeType !== ELEMENT_NODE) {\n return null;\n }\n const { attributes } = node;\n let res;\n for (const attr of attributes) {\n const { name, namespaceURI, prefix, value } = attr;\n if (name === `xmlns:${ns}`) {\n res = value;\n } else if (prefix === ns) {\n res = namespaceURI;\n }\n if (res) {\n break;\n }\n }\n return res ?? null;\n};\n\n/**\n * is namespace declared\n * @param {string} ns - namespace\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isNamespaceDeclared = (ns = '', node = {}) => {\n if (!ns || typeof ns !== 'string' || node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n if (node.lookupNamespaceURI(ns)) {\n return true;\n }\n const root = node.ownerDocument.documentElement;\n let parent = node;\n let res;\n while (parent) {\n res = getNamespaceURI(ns, parent);\n if (res || parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n return !!res;\n};\n\n/**\n * is preceding - nodeA precedes and/or contains nodeB\n * @param {object} nodeA - Element node\n * @param {object} nodeB - Element node\n * @returns {boolean} - result\n */\nexport const isPreceding = (nodeA, nodeB) => {\n if (!nodeA?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeA)}`);\n } else if (!nodeB?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeB)}`);\n }\n if (nodeA.nodeType !== ELEMENT_NODE || nodeB.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const posBit = nodeB.compareDocumentPosition(nodeA);\n const res = posBit & DOCUMENT_POSITION_PRECEDING ||\n posBit & DOCUMENT_POSITION_CONTAINS;\n return !!res;\n};\n\n/**\n * sort nodes\n * @param {Array.<object>|Set.<object>} nodes - collection of nodes\n * @returns {Array.<object|undefined>} - collection of sorted nodes\n */\nexport const sortNodes = (nodes = []) => {\n const arr = [...nodes];\n if (arr.length > 1) {\n arr.sort((a, b) => {\n let res;\n if (isPreceding(b, a)) {\n res = 1;\n } else {\n res = -1;\n }\n return res;\n });\n }\n return arr;\n};\n\n/**\n * init nwsapi\n * @param {object} window - Window\n * @param {object} document - Document\n * @returns {object} - nwsapi\n */\nexport const initNwsapi = (window, document) => {\n if (!window?.DOMException) {\n throw new TypeError(`Unexpected global object ${getType(window)}`);\n }\n if (document?.nodeType !== DOCUMENT_NODE) {\n document = window.document;\n }\n const nw = nwsapi({\n document,\n DOMException: window.DOMException\n });\n nw.configure({\n LOGERRORS: false\n });\n return nw;\n};\n\n/**\n * filter selector (for nwsapi)\n * @param {string} selector - selector\n * @param {object} opt - options\n * @returns {boolean} - result\n */\nexport const filterSelector = (selector, opt = {}) => {\n if (!selector || typeof selector !== 'string') {\n return false;\n }\n // exclude missing close square bracket\n if (selector.includes('[')) {\n const index = selector.lastIndexOf('[');\n const sel = selector.substring(index);\n if (sel.indexOf(']') < 0) {\n return false;\n }\n }\n // exclude namespaced selectors, escaped selectors, pseudo-element selectors,\n // selectors containing non-ASCII or control character other than whitespace,\n // attribute selectors with case flag, e.g. [attr i], or with unclosed quotes,\n // and empty :is() or :where()\n if (/[|\\\\]|::|[^\\u0021-\\u007F\\s]|\\[\\s*[\\w$*=^|~-]+(?:(?:\"[\\w$*=^|~\\s'-]+\"|'[\\w$*=^|~\\s\"-]+')?(?:\\s+[\\w$*=^|~-]+)+|\"[^\"\\]]{1,255}|'[^'\\]]{1,255})\\s*\\]|:(?:is|where)\\(\\s*\\)/.test(selector)) {\n return false;\n }\n // include pseudo-classes that are known to work correctly\n if (selector.includes(':')) {\n const { complex, descend } = opt;\n if (/:(?:is|not)\\(/.test(selector)) {\n if (complex) {\n return !REG_LOGICAL_COMPLEX.test(selector);\n } else {\n return !REG_LOGICAL_COMPOUND.test(selector);\n }\n } else if (descend) {\n return false;\n } else {\n return !REG_WO_LOGICAL.test(selector);\n }\n }\n return true;\n};\n"],
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,sBAAAC,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,sBAAAC,EAAA,oBAAAC,EAAA,mBAAAC,EAAA,gBAAAC,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,gBAAAC,EAAA,cAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAnB,GAKA,IAAAoB,EAAmB,mCACnBC,EAAwB,wBACxBC,EAAgC,iDAGhCC,EAKO,yBACP,MAAMC,EACJ,IAAI,OAAO,OAAO,cAAY,IAAI,MAAI,IAAI,iBAAe,GAAG,EACxDC,EACJ,IAAI,OAAO,OAAO,cAAY,IAAI,MAAI,IAAI,kBAAgB,GAAG,EACzDC,EAAiB,IAAI,OAAO,OAAO,cAAY,IAAI,MAAI,GAAG,EAOnDpB,EAAUqB,GACrB,OAAO,UAAU,SAAS,KAAKA,CAAC,EAAE,MAAM,YAAW,SAAO,EAQ/CX,EAAiBY,GAAQ,CACpC,GAAI,CAACA,GAAM,SACT,MAAM,IAAI,UAAU,mBAAmBtB,EAAQsB,CAAI,CAAC,EAAE,EAExD,IAAIC,EACAC,EACAC,EACJ,OAAQH,EAAK,SAAU,CACrB,KAAK,gBAAe,CAClBC,EAAWD,EACXE,EAAOF,EACP,KACF,CACA,KAAK,yBAAwB,CAC3B,KAAM,CAAE,KAAAI,EAAM,KAAAC,EAAM,cAAAC,CAAc,EAAIN,E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MAAO,CAC9B,MAAMO,EAAOpB,EAAK,YAAY,KAAK,EACnC,GAAIoB,EAAM,CACR,KAAM,CAAE,WAAY,CAAC,CAAE,MAAAW,CAAM,CAAC,CAAE,EAAIR,EAAmBH,CAAI,EAC3D,GAAIW,EAAQ,IAAM,EAChB,MAAO,KAEX,CACF,SAAWtB,EAAY,CACrB,GAAII,IAAc,OAAQ,CACxB,MAAMO,EAAO3C,EAAsBuB,CAAI,EACvC,GAAIoB,EAAM,CACR,KAAM,CAAE,WAAY,CAAC,CAAE,MAAAW,CAAM,CAAC,CAAE,EAAIR,EAAmBH,CAAI,EAC3D,OAAIW,EAAQ,IAAM,EACT,MAEF,KACT,CACF,CACA,KAAM,CAAE,SAAUC,CAAe,EAAIvB,EACrC,GAAIuB,IAAmB,eACrB,OAAOzD,EAAkBkC,CAAU,CAEvC,EACA,MAAO,KACT,EAQa7B,EAAoBoB,GAAQ,CACvC,GAAI,CAACA,GAAM,SACT,MAAM,IAAI,UAAU,mBAAmBtB,EAAQsB,CAAI,CAAC,EAAE,EAExD,GAAIA,EAAK,WAAa,eACpB,MAAO,GAET,GAAI,OAAOA,EAAK,mBAAsB,UACpC,OAAOA,EAAK,kBACP,GAAIA,EAAK,cAAc,aAAe,KAC3C,MAAO,GACF,
|
|
6
|
-
"names": ["utility_exports", "__export", "filterSelector", "getDirectionality", "getNamespaceURI", "getSlottedTextContent", "getType", "initNwsapi", "isContentEditable", "isCustomElement", "isFocusVisible", "isFocusable", "isFocusableArea", "isNamespaceDeclared", "isPreceding", "isVisible", "resolveContent", "sortNodes", "traverseNode", "__toCommonJS", "import_nwsapi", "import_bidi_js", "import_is_potential_custom_element_name", "import_constant", "REG_LOGICAL_COMPLEX", "REG_LOGICAL_COMPOUND", "REG_WO_LOGICAL", "o", "node", "document", "root", "shadow", "host", "mode", "ownerDocument", "refNode", "nodeType", "parentNode", "walker", "bool", "opt", "localName", "formAssociated", "window", "elmConstructor", "attr", "isCustomElementName", "nodes", "text", "item", "dirAttr", "getEmbeddingLevels", "bidiFactory", "valueKeys", "items", "itemDir", "itemLocalName", "itemNodeType", "itemTextContent", "level", "parentNodeType", "
|
|
4
|
+
"sourcesContent": ["/**\n * utility.js\n */\n\n/* import */\nimport nwsapi from '@asamuzakjp/nwsapi';\nimport bidiFactory from 'bidi-js';\nimport isCustomElementName from 'is-potential-custom-element-name';\n\n/* constants */\nimport {\n DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINS,\n DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, KEY_INPUT_BUTTON, KEY_INPUT_EDIT,\n KEY_INPUT_TEXT, LOGICAL_COMPLEX, LOGICAL_COMPOUND, N_TH, PSEUDO_CLASS,\n TEXT_NODE, TYPE_FROM, TYPE_TO, WALKER_FILTER\n} from './constant.js';\nconst REG_LOGICAL_COMPLEX =\n new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH}|${LOGICAL_COMPLEX})`);\nconst REG_LOGICAL_COMPOUND =\n new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH}|${LOGICAL_COMPOUND})`);\nconst REG_WO_LOGICAL = new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH})`);\n\n/**\n * get type\n * @param {*} o - object to check\n * @returns {string} - type of object\n */\nexport const getType = o =>\n Object.prototype.toString.call(o).slice(TYPE_FROM, TYPE_TO);\n\n/**\n * resolve content document, root node and tree walker, is in shadow\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {Array.<object|boolean>}\n * - array of document, root node , tree walker, node is in shadow\n */\nexport const resolveContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let document;\n let root;\n let shadow;\n switch (node.nodeType) {\n case DOCUMENT_NODE: {\n document = node;\n root = node;\n break;\n }\n case DOCUMENT_FRAGMENT_NODE: {\n const { host, mode, ownerDocument } = node;\n document = ownerDocument;\n root = node;\n shadow = host && (mode === 'close' || mode === 'open');\n break;\n }\n case ELEMENT_NODE: {\n document = node.ownerDocument;\n let refNode = node;\n while (refNode) {\n const { host, mode, nodeType, parentNode } = refNode;\n if (nodeType === DOCUMENT_FRAGMENT_NODE) {\n shadow = host && (mode === 'close' || mode === 'open');\n break;\n } else if (parentNode) {\n refNode = parentNode;\n } else {\n break;\n }\n }\n root = refNode;\n break;\n }\n default : {\n throw new TypeError(`Unexpected node ${node.nodeName}`);\n }\n }\n const walker = document.createTreeWalker(root, WALKER_FILTER);\n return [\n document,\n root,\n walker,\n !!shadow\n ];\n};\n\n/**\n * traverse node tree\n * @param {object} node - node\n * @param {object} walker - tree walker\n * @returns {?object} - current node\n */\nexport const traverseNode = (node, walker) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (!walker) {\n return null;\n }\n let refNode = walker.currentNode;\n if (refNode === node) {\n return refNode;\n } else if (refNode.contains(node)) {\n refNode = walker.nextNode();\n while (refNode) {\n if (refNode === node) {\n break;\n }\n refNode = walker.nextNode();\n }\n return refNode;\n } else {\n if (refNode !== walker.root) {\n let bool;\n while (refNode) {\n if (refNode === node) {\n bool = true;\n break;\n } else if (refNode === walker.root) {\n break;\n }\n refNode = walker.parentNode();\n }\n if (bool) {\n return refNode;\n }\n }\n if (node.nodeType === ELEMENT_NODE) {\n let bool;\n while (refNode) {\n if (refNode === node) {\n bool = true;\n break;\n }\n refNode = walker.nextNode();\n }\n if (bool) {\n return refNode;\n }\n }\n }\n return null;\n};\n\n/**\n * is custom element\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - result;\n */\nexport const isCustomElement = (node, opt = {}) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (node.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const { localName, ownerDocument } = node;\n const { formAssociated } = opt;\n const window = ownerDocument.defaultView;\n let elmConstructor;\n const attr = node.getAttribute('is');\n if (attr) {\n elmConstructor =\n isCustomElementName(attr) && window.customElements.get(attr);\n } else {\n elmConstructor =\n isCustomElementName(localName) && window.customElements.get(localName);\n }\n if (elmConstructor) {\n if (formAssociated) {\n return !!elmConstructor.formAssociated;\n }\n return true;\n }\n return false;\n};\n\n/**\n * get slotted text content\n * @param {object} node - Element node\n * @returns {?string} - text content\n */\nexport const getSlottedTextContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (typeof node.assignedNodes !== 'function') {\n return null;\n }\n const nodes = node.assignedNodes();\n if (nodes.length) {\n let text;\n for (const item of nodes) {\n text = item.textContent.trim();\n if (text) {\n break;\n }\n }\n return text;\n }\n return node.textContent.trim();\n};\n\n/**\n * get directionality of node\n * @see https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute\n * @param {object} node - Element node\n * @returns {?string} - 'ltr' / 'rtl'\n */\nexport const getDirectionality = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (node.nodeType !== ELEMENT_NODE) {\n return null;\n }\n const { dir: dirAttr, localName, parentNode } = node;\n const { getEmbeddingLevels } = bidiFactory();\n if (dirAttr === 'ltr' || dirAttr === 'rtl') {\n return dirAttr;\n } else if (dirAttr === 'auto') {\n let text;\n switch (localName) {\n case 'input': {\n const valueKeys = [...KEY_INPUT_BUTTON, ...KEY_INPUT_TEXT, 'hidden'];\n if (!node.type || valueKeys.includes(node.type)) {\n text = node.value;\n } else {\n const ltrKeys = [\n 'checkbox', 'color', 'date', 'image', 'number', 'range', 'radio',\n 'time'\n ];\n if (ltrKeys.includes(node.type)) {\n return 'ltr';\n }\n }\n break;\n }\n case 'slot': {\n text = getSlottedTextContent(node);\n break;\n }\n case 'textarea': {\n text = node.value;\n break;\n }\n default: {\n const items = [].slice.call(node.childNodes);\n for (const item of items) {\n const {\n dir: itemDir, localName: itemLocalName, nodeType: itemNodeType,\n textContent: itemTextContent\n } = item;\n if (itemNodeType === TEXT_NODE) {\n text = itemTextContent.trim();\n } else if (itemNodeType === ELEMENT_NODE) {\n const keys = ['bdi', 'script', 'style', 'textarea'];\n if (!keys.includes(itemLocalName) &&\n (!itemDir || (itemDir !== 'ltr' && itemDir !== 'rtl'))) {\n if (itemLocalName === 'slot') {\n text = getSlottedTextContent(item);\n } else {\n text = itemTextContent.trim();\n }\n }\n }\n if (text) {\n break;\n }\n }\n }\n }\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n return 'rtl';\n }\n } else if (parentNode) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n return getDirectionality(parentNode);\n }\n }\n } else if (localName === 'input' && node.type === 'tel') {\n return 'ltr';\n } else if (localName === 'bdi') {\n const text = node.textContent.trim();\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n return 'rtl';\n }\n }\n } else if (parentNode) {\n if (localName === 'slot') {\n const text = getSlottedTextContent(node);\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n return 'rtl';\n }\n return 'ltr';\n }\n }\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n return getDirectionality(parentNode);\n }\n }\n return 'ltr';\n};\n\n/**\n * is content editable\n * NOTE: not implemented in jsdom https://github.com/jsdom/jsdom/issues/1670\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isContentEditable = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (node.nodeType !== ELEMENT_NODE) {\n return false;\n }\n if (typeof node.isContentEditable === 'boolean') {\n return node.isContentEditable;\n } else if (node.ownerDocument.designMode === 'on') {\n return true;\n } else {\n let attr;\n if (node.hasAttribute('contenteditable')) {\n attr = node.getAttribute('contenteditable');\n } else {\n attr = 'inherit';\n }\n switch (attr) {\n case '':\n case 'true': {\n return true;\n }\n case 'plaintext-only': {\n // FIXME:\n // @see https://github.com/w3c/editing/issues/470\n // @see https://github.com/whatwg/html/issues/10651\n return true;\n }\n case 'false': {\n return false;\n }\n default: {\n if (node?.parentNode?.nodeType === ELEMENT_NODE) {\n return isContentEditable(node.parentNode);\n }\n return false;\n }\n }\n }\n};\n\n/**\n * is node visible\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isVisible = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const window = node.ownerDocument.defaultView;\n const { display, visibility } = window.getComputedStyle(node);\n if (display !== 'none' && visibility === 'visible') {\n return true;\n }\n return false;\n};\n\n/**\n * is focus visible\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusVisible = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const { localName, type } = node;\n switch (localName) {\n case 'input': {\n if (!type || KEY_INPUT_EDIT.includes(type)) {\n return true;\n }\n return false;\n }\n case 'textarea': {\n return true;\n }\n default: {\n return isContentEditable(node);\n }\n }\n};\n\n/**\n * is focusable area\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusableArea = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n if (!node.isConnected) {\n return false;\n }\n const window = node.ownerDocument.defaultView;\n if (node instanceof window.HTMLElement) {\n if (Number.isInteger(parseInt(node.getAttribute('tabindex')))) {\n return true;\n }\n if (isContentEditable(node)) {\n return true;\n }\n const { localName, parentNode } = node;\n switch (localName) {\n case 'a': {\n if (node.href || node.hasAttribute('href')) {\n return true;\n }\n return false;\n }\n case 'iframe': {\n return true;\n }\n case 'input': {\n if (node.disabled || node.hasAttribute('disabled') ||\n node.hidden || node.hasAttribute('hidden')) {\n return false;\n }\n return true;\n }\n case 'summary': {\n if (parentNode.localName === 'details') {\n let child = parentNode.firstElementChild;\n let bool = false;\n while (child) {\n if (child.localName === 'summary') {\n bool = child === node;\n break;\n }\n child = child.nextElementSibling;\n }\n return bool;\n }\n return false;\n }\n default: {\n const keys = ['button', 'select', 'textarea'];\n if (keys.includes(localName) &&\n !(node.disabled || node.hasAttribute('disabled'))) {\n return true;\n }\n }\n }\n } else if (node instanceof window.SVGElement) {\n if (Number.isInteger(parseInt(node.getAttributeNS(null, 'tabindex')))) {\n const keys = [\n 'clipPath', 'defs', 'desc', 'linearGradient', 'marker', 'mask',\n 'metadata', 'pattern', 'radialGradient', 'script', 'style', 'symbol',\n 'title'\n ];\n const ns = 'http://www.w3.org/2000/svg';\n let bool;\n let refNode = node;\n while (refNode.namespaceURI === ns) {\n bool = keys.includes(refNode.localName);\n if (bool) {\n break;\n }\n if (refNode?.parentNode?.namespaceURI === ns) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n if (bool) {\n return false;\n }\n return true;\n }\n if (node.localName === 'a' &&\n (node.href || node.hasAttributeNS(null, 'href'))) {\n return true;\n }\n }\n return false;\n};\n\n/**\n * is focusable\n * NOTE: not applied, need fix in jsdom itself\n * @see https://github.com/whatwg/html/pull/8392\n * @see https://phabricator.services.mozilla.com/D156219\n * @see https://github.com/jsdom/jsdom/issues/3029\n * @see https://github.com/jsdom/jsdom/issues/3464\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusable = node => {\n if (node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const window = node.ownerDocument.defaultView;\n let refNode = node;\n let res = true;\n while (refNode) {\n if (refNode.disabled || refNode.hasAttribute('disabled')) {\n res = false;\n break;\n }\n if (refNode.hidden || refNode.hasAttribute('hidden')) {\n res = false;\n }\n const {\n contentVisibility, display, visibility\n } = window.getComputedStyle(refNode);\n if (display === 'none' || visibility !== 'visible' ||\n (contentVisibility === 'hidden' && refNode !== node)) {\n res = false;\n } else {\n res = true;\n }\n if (res && refNode?.parentNode?.nodeType === ELEMENT_NODE) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n return res;\n};\n\n/**\n * get namespace URI\n * @param {string} ns - namespace prefix\n * @param {Array} node - Element node\n * @returns {?string} - namespace URI\n */\nexport const getNamespaceURI = (ns, node) => {\n if (typeof ns !== 'string') {\n throw new TypeError(`Unexpected type ${getType(ns)}`);\n } else if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n if (!ns || node.nodeType !== ELEMENT_NODE) {\n return null;\n }\n const { attributes } = node;\n let res;\n for (const attr of attributes) {\n const { name, namespaceURI, prefix, value } = attr;\n if (name === `xmlns:${ns}`) {\n res = value;\n } else if (prefix === ns) {\n res = namespaceURI;\n }\n if (res) {\n break;\n }\n }\n return res ?? null;\n};\n\n/**\n * is namespace declared\n * @param {string} ns - namespace\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isNamespaceDeclared = (ns = '', node = {}) => {\n if (!ns || typeof ns !== 'string' || node?.nodeType !== ELEMENT_NODE) {\n return false;\n }\n if (node.lookupNamespaceURI(ns)) {\n return true;\n }\n const root = node.ownerDocument.documentElement;\n let parent = node;\n let res;\n while (parent) {\n res = getNamespaceURI(ns, parent);\n if (res || parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n return !!res;\n};\n\n/**\n * is preceding - nodeA precedes and/or contains nodeB\n * @param {object} nodeA - Element node\n * @param {object} nodeB - Element node\n * @returns {boolean} - result\n */\nexport const isPreceding = (nodeA, nodeB) => {\n if (!nodeA?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeA)}`);\n } else if (!nodeB?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeB)}`);\n }\n if (nodeA.nodeType !== ELEMENT_NODE || nodeB.nodeType !== ELEMENT_NODE) {\n return false;\n }\n const posBit = nodeB.compareDocumentPosition(nodeA);\n const res = posBit & DOCUMENT_POSITION_PRECEDING ||\n posBit & DOCUMENT_POSITION_CONTAINS;\n return !!res;\n};\n\n/**\n * sort nodes\n * @param {Array.<object>|Set.<object>} nodes - collection of nodes\n * @returns {Array.<object|undefined>} - collection of sorted nodes\n */\nexport const sortNodes = (nodes = []) => {\n const arr = [...nodes];\n if (arr.length > 1) {\n arr.sort((a, b) => {\n let res;\n if (isPreceding(b, a)) {\n res = 1;\n } else {\n res = -1;\n }\n return res;\n });\n }\n return arr;\n};\n\n/**\n * init nwsapi\n * @param {object} window - Window\n * @param {object} document - Document\n * @returns {object} - nwsapi\n */\nexport const initNwsapi = (window, document) => {\n if (!window?.DOMException) {\n throw new TypeError(`Unexpected global object ${getType(window)}`);\n }\n if (document?.nodeType !== DOCUMENT_NODE) {\n document = window.document;\n }\n const nw = nwsapi({\n document,\n DOMException: window.DOMException\n });\n nw.configure({\n LOGERRORS: false\n });\n return nw;\n};\n\n/**\n * filter selector (for nwsapi)\n * @param {string} selector - selector\n * @param {object} opt - options\n * @returns {boolean} - result\n */\nexport const filterSelector = (selector, opt = {}) => {\n if (!selector || typeof selector !== 'string') {\n return false;\n }\n // exclude missing close square bracket\n if (selector.includes('[')) {\n const index = selector.lastIndexOf('[');\n const sel = selector.substring(index);\n if (sel.indexOf(']') < 0) {\n return false;\n }\n }\n // exclude namespaced selectors, escaped selectors, pseudo-element selectors,\n // selectors containing non-ASCII or control character other than whitespace,\n // attribute selectors with case flag, e.g. [attr i], or with unclosed quotes,\n // and empty :is() or :where()\n if (/[|\\\\]|::|[^\\u0021-\\u007F\\s]|\\[\\s*[\\w$*=^|~-]+(?:(?:\"[\\w$*=^|~\\s'-]+\"|'[\\w$*=^|~\\s\"-]+')?(?:\\s+[\\w$*=^|~-]+)+|\"[^\"\\]]{1,255}|'[^'\\]]{1,255})\\s*\\]|:(?:is|where)\\(\\s*\\)/.test(selector)) {\n return false;\n }\n // include pseudo-classes that are known to work correctly\n if (selector.includes(':')) {\n const { complex, descend } = opt;\n if (/:(?:is|not)\\(/.test(selector)) {\n if (complex) {\n return !REG_LOGICAL_COMPLEX.test(selector);\n } else {\n return !REG_LOGICAL_COMPOUND.test(selector);\n }\n } else if (descend) {\n return false;\n } else {\n return !REG_WO_LOGICAL.test(selector);\n }\n }\n return true;\n};\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAA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,CAAC,EACD,OAAAsC,EAAG,UAAU,CACX,UAAW,EACb,CAAC,EACMA,CACT,EAQa/E,EAAiB,CAACiF,EAAU3C,EAAM,CAAC,IAAM,CACpD,GAAI,CAAC2C,GAAY,OAAOA,GAAa,SACnC,MAAO,GAGT,GAAIA,EAAS,SAAS,GAAG,EAAG,CAC1B,MAAMC,EAAQD,EAAS,YAAY,GAAG,EAEtC,GADYA,EAAS,UAAUC,CAAK,EAC5B,QAAQ,GAAG,EAAI,EACrB,MAAO,EAEX,CAKA,GAAI,wKAAwK,KAAKD,CAAQ,EACvL,MAAO,GAGT,GAAIA,EAAS,SAAS,GAAG,EAAG,CAC1B,KAAM,CAAE,QAAAE,EAAS,QAAAC,CAAQ,EAAI9C,EAC7B,MAAI,gBAAgB,KAAK2C,CAAQ,EAC3BE,EACK,CAAC7D,EAAoB,KAAK2D,CAAQ,EAElC,CAAC1D,EAAqB,KAAK0D,CAAQ,EAEnCG,EACF,GAEA,CAAC5D,EAAe,KAAKyD,CAAQ,CAExC,CACA,MAAO,EACT",
|
|
6
|
+
"names": ["utility_exports", "__export", "filterSelector", "getDirectionality", "getNamespaceURI", "getSlottedTextContent", "getType", "initNwsapi", "isContentEditable", "isCustomElement", "isFocusVisible", "isFocusable", "isFocusableArea", "isNamespaceDeclared", "isPreceding", "isVisible", "resolveContent", "sortNodes", "traverseNode", "__toCommonJS", "import_nwsapi", "import_bidi_js", "import_is_potential_custom_element_name", "import_constant", "REG_LOGICAL_COMPLEX", "REG_LOGICAL_COMPOUND", "REG_WO_LOGICAL", "o", "node", "document", "root", "shadow", "host", "mode", "ownerDocument", "refNode", "nodeType", "parentNode", "walker", "bool", "opt", "localName", "formAssociated", "window", "elmConstructor", "attr", "isCustomElementName", "nodes", "text", "item", "dirAttr", "getEmbeddingLevels", "bidiFactory", "valueKeys", "items", "itemDir", "itemLocalName", "itemNodeType", "itemTextContent", "level", "parentNodeType", "display", "visibility", "type", "child", "keys", "ns", "res", "contentVisibility", "attributes", "name", "namespaceURI", "prefix", "value", "parent", "nodeA", "nodeB", "posBit", "arr", "a", "b", "nw", "nwsapi", "selector", "index", "complex", "descend"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"types": "types/index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@asamuzakjp/nwsapi": "^2.2.
|
|
26
|
+
"@asamuzakjp/nwsapi": "^2.2.24",
|
|
27
27
|
"bidi-js": "^1.0.3",
|
|
28
|
-
"css-tree": "^3.0.
|
|
28
|
+
"css-tree": "^3.0.1",
|
|
29
29
|
"is-potential-custom-element-name": "^1.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"chai": "^5.1.2",
|
|
36
36
|
"commander": "^12.1.0",
|
|
37
37
|
"esbuild": "^0.24.0",
|
|
38
|
-
"eslint": "^9.
|
|
39
|
-
"eslint-plugin-import-x": "^4.
|
|
38
|
+
"eslint": "^9.14.0",
|
|
39
|
+
"eslint-plugin-import-x": "^4.4.0",
|
|
40
40
|
"eslint-plugin-jsdoc": "^50.4.3",
|
|
41
41
|
"eslint-plugin-regexp": "^2.6.0",
|
|
42
42
|
"eslint-plugin-unicorn": "^56.0.0",
|
|
43
43
|
"globals": "^15.11.0",
|
|
44
|
-
"happy-dom": "^15.
|
|
44
|
+
"happy-dom": "^15.8.0",
|
|
45
45
|
"jsdom": "^25.0.1",
|
|
46
46
|
"linkedom": "^0.18.5",
|
|
47
|
-
"mocha": "^10.
|
|
47
|
+
"mocha": "^10.8.2",
|
|
48
48
|
"neostandard": "^0.11.7",
|
|
49
49
|
"sinon": "^19.0.2",
|
|
50
50
|
"typescript": "^5.6.3",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"tsc": "node scripts/index clean --dir=types -i && npx tsc",
|
|
65
65
|
"update-wpt": "git submodule update --init --recursive --remote"
|
|
66
66
|
},
|
|
67
|
-
"version": "6.2.
|
|
67
|
+
"version": "6.2.2"
|
|
68
68
|
}
|
package/src/js/constant.js
CHANGED
|
@@ -57,8 +57,7 @@ export const ALPHA_NUM = '[A-Z\\d]+';
|
|
|
57
57
|
export const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)';
|
|
58
58
|
export const DIGIT = '(?:0|[1-9]\\d*)';
|
|
59
59
|
export const LANG_PART = `(?:-${ALPHA_NUM})*`;
|
|
60
|
-
export const PSEUDO_CLASS =
|
|
61
|
-
`(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|root|target|visited`;
|
|
60
|
+
export const PSEUDO_CLASS = `(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|read-(?:only|write)|root|target`;
|
|
62
61
|
export const ANB =
|
|
63
62
|
`[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\s*[+-]\\s*${DIGIT}`;
|
|
64
63
|
// N_TH: excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo)
|
package/src/js/utility.js
CHANGED
|
@@ -328,36 +328,35 @@ export const isContentEditable = node => {
|
|
|
328
328
|
return node.isContentEditable;
|
|
329
329
|
} else if (node.ownerDocument.designMode === 'on') {
|
|
330
330
|
return true;
|
|
331
|
-
} else
|
|
332
|
-
|
|
331
|
+
} else {
|
|
332
|
+
let attr;
|
|
333
|
+
if (node.hasAttribute('contenteditable')) {
|
|
334
|
+
attr = node.getAttribute('contenteditable');
|
|
335
|
+
} else {
|
|
336
|
+
attr = 'inherit';
|
|
337
|
+
}
|
|
333
338
|
switch (attr) {
|
|
334
339
|
case '':
|
|
335
340
|
case 'true': {
|
|
336
341
|
return true;
|
|
337
342
|
}
|
|
338
343
|
case 'plaintext-only': {
|
|
339
|
-
// FIXME:
|
|
340
|
-
//
|
|
344
|
+
// FIXME:
|
|
345
|
+
// @see https://github.com/w3c/editing/issues/470
|
|
346
|
+
// @see https://github.com/whatwg/html/issues/10651
|
|
341
347
|
return true;
|
|
342
348
|
}
|
|
343
349
|
case 'false': {
|
|
344
350
|
return false;
|
|
345
351
|
}
|
|
346
352
|
default: {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
while (parent) {
|
|
350
|
-
if (isContentEditable(parent)) {
|
|
351
|
-
bool = true;
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
parent = parent.parentNode;
|
|
353
|
+
if (node?.parentNode?.nodeType === ELEMENT_NODE) {
|
|
354
|
+
return isContentEditable(node.parentNode);
|
|
355
355
|
}
|
|
356
|
-
return
|
|
356
|
+
return false;
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
return false;
|
|
361
360
|
};
|
|
362
361
|
|
|
363
362
|
/**
|
package/types/js/constant.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const ALPHA_NUM: "[A-Z\\d]+";
|
|
|
44
44
|
export const CHILD_IDX: "(?:first|last|only)-(?:child|of-type)";
|
|
45
45
|
export const DIGIT: "(?:0|[1-9]\\d*)";
|
|
46
46
|
export const LANG_PART: "(?:-[A-Z\\d]+)*";
|
|
47
|
-
export const PSEUDO_CLASS: "(?:any-)?link|(?:first|last|only)-(?:child|of-type)|checked|empty|indeterminate|root|target
|
|
47
|
+
export const PSEUDO_CLASS: "(?:any-)?link|(?:first|last|only)-(?:child|of-type)|checked|empty|indeterminate|read-(?:only|write)|root|target";
|
|
48
48
|
export const ANB: "[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*)";
|
|
49
49
|
export const N_TH: "nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*))\\s*\\)";
|
|
50
50
|
export const SUB_TYPE: "\\[[^|\\]]+\\]|[#.:][\\w-]+";
|