@uiw/react-md-editor 3.20.0 → 3.20.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/README.md +3 -0
- package/dist/mdeditor.js +1155 -1247
- package/dist/mdeditor.min.js +1 -1
- package/esm/Editor.d.ts +1 -1
- package/esm/Editor.js.map +1 -1
- package/esm/commands/index.d.ts +2 -1
- package/esm/commands/index.js +1 -1
- package/esm/commands/index.js.map +2 -2
- package/esm/commands/title1.js.map +1 -1
- package/esm/commands/title2.js.map +1 -1
- package/esm/commands/title3.js.map +1 -1
- package/esm/commands/title4.js.map +1 -1
- package/esm/commands/title5.js.map +1 -1
- package/esm/commands/title6.js.map +1 -1
- package/lib/Editor.d.ts +1 -1
- package/lib/Editor.js.map +1 -1
- package/lib/commands/index.d.ts +2 -1
- package/lib/commands/index.js +6 -0
- package/lib/commands/index.js.map +2 -2
- package/lib/commands/title1.js.map +1 -1
- package/lib/commands/title2.js.map +1 -1
- package/lib/commands/title3.js.map +1 -1
- package/lib/commands/title4.js.map +1 -1
- package/lib/commands/title5.js.map +1 -1
- package/lib/commands/title6.js.map +1 -1
- package/package.json +1 -1
- package/src/Editor.tsx +1 -1
- package/src/commands/index.ts +1 -0
package/dist/mdeditor.js
CHANGED
|
@@ -9469,6 +9469,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
9469
9469
|
"codeLive": () => (/* reexport */ codeLive),
|
|
9470
9470
|
"codePreview": () => (/* reexport */ codePreview),
|
|
9471
9471
|
"commands": () => (/* reexport */ commands_namespaceObject),
|
|
9472
|
+
"comment": () => (/* reexport */ commands_comment_comment),
|
|
9472
9473
|
"default": () => (/* binding */ src_0),
|
|
9473
9474
|
"divider": () => (/* reexport */ divider),
|
|
9474
9475
|
"fullscreen": () => (/* reexport */ fullscreen),
|
|
@@ -9549,6 +9550,7 @@ __webpack_require__.d(commands_namespaceObject, {
|
|
|
9549
9550
|
"codeEdit": () => (codeEdit),
|
|
9550
9551
|
"codeLive": () => (codeLive),
|
|
9551
9552
|
"codePreview": () => (codePreview),
|
|
9553
|
+
"comment": () => (commands_comment_comment),
|
|
9552
9554
|
"divider": () => (divider),
|
|
9553
9555
|
"fullscreen": () => (fullscreen),
|
|
9554
9556
|
"getCommands": () => (commands_getCommands),
|
|
@@ -9659,9 +9661,7 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
9659
9661
|
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
9660
9662
|
if (Object(_i) !== _i) return;
|
|
9661
9663
|
_n = !1;
|
|
9662
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0)
|
|
9663
|
-
;
|
|
9664
|
-
}
|
|
9664
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
9665
9665
|
} catch (err) {
|
|
9666
9666
|
_d = !0, _e = err;
|
|
9667
9667
|
} finally {
|
|
@@ -9677,9 +9677,7 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
9677
9677
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
9678
9678
|
function _arrayLikeToArray(arr, len) {
|
|
9679
9679
|
if (len == null || len > arr.length) len = arr.length;
|
|
9680
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
9681
|
-
arr2[i] = arr[i];
|
|
9682
|
-
}
|
|
9680
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
9683
9681
|
return arr2;
|
|
9684
9682
|
}
|
|
9685
9683
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
@@ -31387,7 +31385,7 @@ function rehypeAutolinkHeadings(options = {}) {
|
|
|
31387
31385
|
}
|
|
31388
31386
|
|
|
31389
31387
|
;// CONCATENATED MODULE: ../node_modules/rehype-attr/lib/utils.js
|
|
31390
|
-
const getURLParameters = (url) => (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {});
|
|
31388
|
+
const getURLParameters = (url = '') => (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {});
|
|
31391
31389
|
const prevChild = (data = [], index) => {
|
|
31392
31390
|
let i = index;
|
|
31393
31391
|
while (i > -1) {
|
|
@@ -31418,8 +31416,8 @@ const nextChild = (data = [], index, tagName, codeBlockParames) => {
|
|
|
31418
31416
|
return;
|
|
31419
31417
|
if (element.type === 'text' && element.value.replace(/(\n|\s)/g, '') !== '')
|
|
31420
31418
|
return;
|
|
31421
|
-
if (/^(comment|raw)$/ig.test(element
|
|
31422
|
-
if (!/^rehype:/.test(element.value
|
|
31419
|
+
if (element.type && /^(comment|raw)$/ig.test(element.type)) {
|
|
31420
|
+
if (element.value && !/^rehype:/.test(element.value.replace(/^(\s+)?<!--(.*?)-->/, '$2') || '')) {
|
|
31423
31421
|
return;
|
|
31424
31422
|
}
|
|
31425
31423
|
;
|
|
@@ -31427,11 +31425,11 @@ const nextChild = (data = [], index, tagName, codeBlockParames) => {
|
|
|
31427
31425
|
const nextNode = nextChild(data, i, 'pre', codeBlockParames);
|
|
31428
31426
|
if (nextNode)
|
|
31429
31427
|
return;
|
|
31430
|
-
element.value = element.value
|
|
31428
|
+
element.value = (element.value || '').replace(/^(\n|\s)+/, '');
|
|
31431
31429
|
return element;
|
|
31432
31430
|
}
|
|
31433
31431
|
else {
|
|
31434
|
-
element.value = element.value
|
|
31432
|
+
element.value = (element.value || '').replace(/^(\n|\s)+/, '');
|
|
31435
31433
|
return element;
|
|
31436
31434
|
}
|
|
31437
31435
|
}
|
|
@@ -58433,36 +58431,13 @@ function direction(value) {
|
|
|
58433
58431
|
return rtl.test(source) ? 'rtl' : ltr.test(source) ? 'ltr' : 'neutral'
|
|
58434
58432
|
}
|
|
58435
58433
|
|
|
58436
|
-
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/util.js
|
|
58437
|
-
/**
|
|
58438
|
-
* @typedef {import('./types.js').Node} Node
|
|
58439
|
-
* @typedef {import('./types.js').Element} Element
|
|
58440
|
-
* @typedef {import('./types.js').Parent} Parent
|
|
58441
|
-
* @typedef {import('hast-util-is-element').AssertPredicate<Element>} IsElement
|
|
58442
|
-
*/
|
|
58443
|
-
|
|
58444
|
-
|
|
58445
|
-
|
|
58446
|
-
/**
|
|
58447
|
-
* @param {Node} node
|
|
58448
|
-
* @returns {node is Parent}
|
|
58449
|
-
*/
|
|
58450
|
-
function util_parent(node) {
|
|
58451
|
-
// @ts-expect-error: hush.
|
|
58452
|
-
return Array.isArray(node.children)
|
|
58453
|
-
}
|
|
58454
|
-
|
|
58455
|
-
/** @type {IsElement} */
|
|
58456
|
-
// @ts-expect-error it works.
|
|
58457
|
-
const util_element = convertElement()
|
|
58458
|
-
|
|
58459
58434
|
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/enter-state.js
|
|
58460
58435
|
/**
|
|
58461
58436
|
* @typedef {import('./types.js').SelectState} SelectState
|
|
58462
|
-
* @typedef {import('./types.js').
|
|
58437
|
+
* @typedef {import('./types.js').Node} Node
|
|
58463
58438
|
* @typedef {import('./types.js').ElementChild} ElementChild
|
|
58464
58439
|
* @typedef {import('./types.js').Direction} Direction
|
|
58465
|
-
* @typedef {import('unist-util-visit/complex-types').Visitor<ElementChild>} Visitor
|
|
58440
|
+
* @typedef {import('unist-util-visit/complex-types.js').Visitor<ElementChild>} Visitor
|
|
58466
58441
|
*/
|
|
58467
58442
|
|
|
58468
58443
|
|
|
@@ -58470,12 +58445,19 @@ const util_element = convertElement()
|
|
|
58470
58445
|
|
|
58471
58446
|
|
|
58472
58447
|
|
|
58473
|
-
|
|
58474
|
-
|
|
58475
58448
|
/**
|
|
58449
|
+
* Enter a node.
|
|
58450
|
+
*
|
|
58451
|
+
* The caller is responsible for calling the return value `exit`.
|
|
58452
|
+
*
|
|
58476
58453
|
* @param {SelectState} state
|
|
58477
|
-
*
|
|
58454
|
+
* Current state.
|
|
58455
|
+
*
|
|
58456
|
+
* Will be mutated: `exit` undos the changes.
|
|
58457
|
+
* @param {Node} node
|
|
58458
|
+
* Node to enter.
|
|
58478
58459
|
* @returns {() => void}
|
|
58460
|
+
* Call to exit.
|
|
58479
58461
|
*/
|
|
58480
58462
|
// eslint-disable-next-line complexity
|
|
58481
58463
|
function enterState(state, node) {
|
|
@@ -58483,30 +58465,25 @@ function enterState(state, node) {
|
|
|
58483
58465
|
const language = state.language
|
|
58484
58466
|
const currentDirection = state.direction
|
|
58485
58467
|
const editableOrEditingHost = state.editableOrEditingHost
|
|
58486
|
-
/** @type {Direction|undefined} */
|
|
58468
|
+
/** @type {Direction | undefined} */
|
|
58487
58469
|
let dirInferred
|
|
58488
|
-
/** @type {boolean|undefined} */
|
|
58489
|
-
let found
|
|
58490
58470
|
|
|
58491
|
-
if (
|
|
58471
|
+
if (node.type === 'element' && node.properties) {
|
|
58492
58472
|
const lang = node.properties.xmlLang || node.properties.lang
|
|
58493
58473
|
const type = node.properties.type || 'text'
|
|
58494
58474
|
const dir = dirProperty(node)
|
|
58495
58475
|
|
|
58496
58476
|
if (lang !== undefined && lang !== null) {
|
|
58497
58477
|
state.language = String(lang)
|
|
58498
|
-
found = true
|
|
58499
58478
|
}
|
|
58500
58479
|
|
|
58501
58480
|
if (schema && schema.space === 'html') {
|
|
58502
58481
|
if (node.properties.contentEditable === 'true') {
|
|
58503
58482
|
state.editableOrEditingHost = true
|
|
58504
|
-
found = true
|
|
58505
58483
|
}
|
|
58506
58484
|
|
|
58507
|
-
if (
|
|
58485
|
+
if (node.tagName === 'svg') {
|
|
58508
58486
|
state.schema = property_information_svg
|
|
58509
|
-
found = true
|
|
58510
58487
|
}
|
|
58511
58488
|
|
|
58512
58489
|
// See: <https://html.spec.whatwg.org/#the-directionality>.
|
|
@@ -58517,25 +58494,24 @@ function enterState(state, node) {
|
|
|
58517
58494
|
// Explicit `[dir=ltr]`.
|
|
58518
58495
|
dir === 'ltr' ||
|
|
58519
58496
|
// HTML with an invalid or no `[dir]`.
|
|
58520
|
-
(dir !== 'auto' &&
|
|
58497
|
+
(dir !== 'auto' && node.tagName === 'html') ||
|
|
58521
58498
|
// `input[type=tel]` with an invalid or no `[dir]`.
|
|
58522
|
-
(dir !== 'auto' &&
|
|
58499
|
+
(dir !== 'auto' && node.tagName === 'input' && type === 'tel')
|
|
58523
58500
|
) {
|
|
58524
58501
|
dirInferred = 'ltr'
|
|
58525
58502
|
// `[dir=auto]` or `bdi` with an invalid or no `[dir]`.
|
|
58526
|
-
} else if (dir === 'auto' ||
|
|
58527
|
-
if (
|
|
58503
|
+
} else if (dir === 'auto' || node.tagName === 'bdi') {
|
|
58504
|
+
if (node.tagName === 'textarea') {
|
|
58528
58505
|
// Check contents of `<textarea>`.
|
|
58529
58506
|
dirInferred = dirBidi(hast_util_to_string_toString(node))
|
|
58530
58507
|
} else if (
|
|
58531
|
-
|
|
58508
|
+
node.tagName === 'input' &&
|
|
58532
58509
|
(type === 'email' ||
|
|
58533
58510
|
type === 'search' ||
|
|
58534
58511
|
type === 'tel' ||
|
|
58535
58512
|
type === 'text')
|
|
58536
58513
|
) {
|
|
58537
58514
|
// Check value of `<input>`.
|
|
58538
|
-
// @ts-expect-error something is `never` in types but this is needed.
|
|
58539
58515
|
dirInferred = node.properties.value
|
|
58540
58516
|
? // @ts-expect-error Assume string
|
|
58541
58517
|
dirBidi(node.properties.value)
|
|
@@ -58548,17 +58524,15 @@ function enterState(state, node) {
|
|
|
58548
58524
|
|
|
58549
58525
|
if (dirInferred) {
|
|
58550
58526
|
state.direction = dirInferred
|
|
58551
|
-
found = true
|
|
58552
58527
|
}
|
|
58553
58528
|
}
|
|
58554
58529
|
// Turn off editing mode in non-HTML spaces.
|
|
58555
58530
|
else if (state.editableOrEditingHost) {
|
|
58556
58531
|
state.editableOrEditingHost = false
|
|
58557
|
-
found = true
|
|
58558
58532
|
}
|
|
58559
58533
|
}
|
|
58560
58534
|
|
|
58561
|
-
return
|
|
58535
|
+
return reset
|
|
58562
58536
|
|
|
58563
58537
|
function reset() {
|
|
58564
58538
|
state.schema = schema
|
|
@@ -58571,12 +58545,16 @@ function enterState(state, node) {
|
|
|
58571
58545
|
function inferDirectionality(child) {
|
|
58572
58546
|
if (child.type === 'text') {
|
|
58573
58547
|
dirInferred = dirBidi(child.value)
|
|
58574
|
-
return dirInferred ? EXIT :
|
|
58548
|
+
return dirInferred ? EXIT : undefined
|
|
58575
58549
|
}
|
|
58576
58550
|
|
|
58577
58551
|
if (
|
|
58578
58552
|
child !== node &&
|
|
58579
|
-
|
|
58553
|
+
child.type === 'element' &&
|
|
58554
|
+
(child.tagName === 'bdi' ||
|
|
58555
|
+
child.tagName === 'script' ||
|
|
58556
|
+
child.tagName === 'style' ||
|
|
58557
|
+
child.tagName === 'textare' ||
|
|
58580
58558
|
dirProperty(child))
|
|
58581
58559
|
) {
|
|
58582
58560
|
return SKIP
|
|
@@ -58586,7 +58564,7 @@ function enterState(state, node) {
|
|
|
58586
58564
|
|
|
58587
58565
|
/**
|
|
58588
58566
|
* @param {string} value
|
|
58589
|
-
* @returns {Direction|undefined}
|
|
58567
|
+
* @returns {Direction | undefined}
|
|
58590
58568
|
*/
|
|
58591
58569
|
function dirBidi(value) {
|
|
58592
58570
|
const result = direction(value)
|
|
@@ -58595,11 +58573,13 @@ function dirBidi(value) {
|
|
|
58595
58573
|
|
|
58596
58574
|
/**
|
|
58597
58575
|
* @param {ElementChild} node
|
|
58598
|
-
* @returns {Direction|undefined}
|
|
58576
|
+
* @returns {Direction | undefined}
|
|
58599
58577
|
*/
|
|
58600
58578
|
function dirProperty(node) {
|
|
58601
58579
|
const value =
|
|
58602
|
-
|
|
58580
|
+
node.type === 'element' &&
|
|
58581
|
+
node.properties &&
|
|
58582
|
+
typeof node.properties.dir === 'string'
|
|
58603
58583
|
? node.properties.dir.toLowerCase()
|
|
58604
58584
|
: undefined
|
|
58605
58585
|
|
|
@@ -58608,231 +58588,297 @@ function dirProperty(node) {
|
|
|
58608
58588
|
: undefined
|
|
58609
58589
|
}
|
|
58610
58590
|
|
|
58611
|
-
|
|
58612
|
-
|
|
58613
|
-
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/nest.js
|
|
58591
|
+
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/attribute.js
|
|
58614
58592
|
/**
|
|
58615
58593
|
* @typedef {import('./types.js').Rule} Rule
|
|
58616
|
-
* @typedef {import('./types.js').
|
|
58594
|
+
* @typedef {import('./types.js').RuleAttr} RuleAttr
|
|
58617
58595
|
* @typedef {import('./types.js').Element} Element
|
|
58618
|
-
* @typedef {import('./types.js').
|
|
58619
|
-
* @typedef {import('./types.js').
|
|
58620
|
-
* @typedef {import('./types.js').
|
|
58621
|
-
* @typedef {import('./types.js').Handler} Handler
|
|
58596
|
+
* @typedef {import('./types.js').Schema} Schema
|
|
58597
|
+
* @typedef {import('./types.js').Info} Info
|
|
58598
|
+
* @typedef {import('./types.js').PropertyValue} PropertyValue
|
|
58622
58599
|
*/
|
|
58623
58600
|
|
|
58624
58601
|
|
|
58625
58602
|
|
|
58626
58603
|
|
|
58627
58604
|
|
|
58628
|
-
const nest_own = {}.hasOwnProperty
|
|
58629
58605
|
|
|
58630
|
-
|
|
58631
|
-
|
|
58632
|
-
|
|
58606
|
+
|
|
58607
|
+
/** @type {(query: RuleAttr, element: Element, info: Info) => boolean} */
|
|
58608
|
+
const handle = zwitch('operator', {
|
|
58609
|
+
unknown: unknownOperator,
|
|
58633
58610
|
// @ts-expect-error: hush.
|
|
58634
|
-
invalid:
|
|
58611
|
+
invalid: exists,
|
|
58635
58612
|
handlers: {
|
|
58636
|
-
|
|
58637
|
-
|
|
58638
|
-
|
|
58639
|
-
'
|
|
58640
|
-
|
|
58641
|
-
'
|
|
58642
|
-
// @ts-expect-error: hush.
|
|
58643
|
-
'~': generalSibling
|
|
58613
|
+
'=': exact,
|
|
58614
|
+
'~=': spaceSeparatedList,
|
|
58615
|
+
'|=': exactOrPrefix,
|
|
58616
|
+
'^=': begins,
|
|
58617
|
+
'$=': ends,
|
|
58618
|
+
'*=': contains
|
|
58644
58619
|
}
|
|
58645
58620
|
})
|
|
58646
58621
|
|
|
58647
|
-
/** @type {Handler} */
|
|
58648
|
-
function nest(query, node, index, parent, state) {
|
|
58649
|
-
handle(query, node, index, parent, state)
|
|
58650
|
-
}
|
|
58651
|
-
|
|
58652
|
-
// Shouldn’t be called, parser gives correct data.
|
|
58653
|
-
/* c8 ignore next 6 */
|
|
58654
58622
|
/**
|
|
58655
|
-
* @param {
|
|
58623
|
+
* @param {Rule} query
|
|
58624
|
+
* @param {Element} element
|
|
58625
|
+
* @param {Schema} schema
|
|
58626
|
+
* @returns {boolean}
|
|
58656
58627
|
*/
|
|
58657
|
-
function
|
|
58658
|
-
|
|
58659
|
-
|
|
58628
|
+
function attribute(query, element, schema) {
|
|
58629
|
+
const attrs = query.attrs
|
|
58630
|
+
let index = -1
|
|
58660
58631
|
|
|
58661
|
-
|
|
58662
|
-
|
|
58663
|
-
|
|
58664
|
-
|
|
58665
|
-
if (parent || index === null) {
|
|
58666
|
-
throw new Error('topScan is supposed to be called from the root node')
|
|
58632
|
+
while (++index < attrs.length) {
|
|
58633
|
+
if (!handle(attrs[index], element, find(schema, attrs[index].name))) {
|
|
58634
|
+
return false
|
|
58635
|
+
}
|
|
58667
58636
|
}
|
|
58668
58637
|
|
|
58669
|
-
|
|
58670
|
-
|
|
58671
|
-
if (!state.iterator) {
|
|
58672
|
-
throw new Error('Expected `iterator`')
|
|
58673
|
-
}
|
|
58638
|
+
return true
|
|
58639
|
+
}
|
|
58674
58640
|
|
|
58675
|
-
|
|
58676
|
-
|
|
58641
|
+
/**
|
|
58642
|
+
* Check whether an attribute exists.
|
|
58643
|
+
*
|
|
58644
|
+
* `[attr]`
|
|
58645
|
+
*
|
|
58646
|
+
* @param {RuleAttr} _
|
|
58647
|
+
* @param {Element} element
|
|
58648
|
+
* @param {Info} info
|
|
58649
|
+
* @returns {boolean}
|
|
58650
|
+
*/
|
|
58651
|
+
function exists(_, element, info) {
|
|
58652
|
+
return hasProperty(element, info.property)
|
|
58677
58653
|
}
|
|
58678
58654
|
|
|
58679
|
-
/**
|
|
58680
|
-
|
|
58681
|
-
|
|
58655
|
+
/**
|
|
58656
|
+
* Check whether an attribute has an exact value.
|
|
58657
|
+
*
|
|
58658
|
+
* `[attr=value]`
|
|
58659
|
+
*
|
|
58660
|
+
* @param {RuleAttr} query
|
|
58661
|
+
* @param {Element} element
|
|
58662
|
+
* @param {Info} info
|
|
58663
|
+
* @returns {boolean}
|
|
58664
|
+
*/
|
|
58665
|
+
function exact(query, element, info) {
|
|
58666
|
+
return Boolean(
|
|
58667
|
+
hasProperty(element, info.property) &&
|
|
58668
|
+
element.properties &&
|
|
58669
|
+
normalizeValue(element.properties[info.property], info) === query.value
|
|
58670
|
+
)
|
|
58671
|
+
}
|
|
58682
58672
|
|
|
58683
|
-
|
|
58684
|
-
|
|
58673
|
+
/**
|
|
58674
|
+
* Check whether an attribute, interpreted as a space-separated list, contains
|
|
58675
|
+
* a value.
|
|
58676
|
+
*
|
|
58677
|
+
* `[attr~=value]`
|
|
58678
|
+
*
|
|
58679
|
+
* @param {RuleAttr} query
|
|
58680
|
+
* @param {Element} element
|
|
58681
|
+
* @param {Info} info
|
|
58682
|
+
* @returns {boolean}
|
|
58683
|
+
*/
|
|
58684
|
+
function spaceSeparatedList(query, element, info) {
|
|
58685
|
+
const value = element.properties && element.properties[info.property]
|
|
58685
58686
|
|
|
58686
|
-
|
|
58687
|
-
|
|
58688
|
-
//
|
|
58689
|
-
|
|
58690
|
-
|
|
58691
|
-
|
|
58692
|
-
|
|
58687
|
+
return (
|
|
58688
|
+
// If this is a space-separated list, and the query is contained in it, return
|
|
58689
|
+
// true.
|
|
58690
|
+
(!info.commaSeparated &&
|
|
58691
|
+
value &&
|
|
58692
|
+
typeof value === 'object' &&
|
|
58693
|
+
query.value &&
|
|
58694
|
+
value.includes(query.value)) ||
|
|
58695
|
+
// For all other values (including comma-separated lists), return whether this
|
|
58696
|
+
// is an exact match.
|
|
58697
|
+
(hasProperty(element, info.property) &&
|
|
58698
|
+
normalizeValue(value, info) === query.value)
|
|
58699
|
+
)
|
|
58700
|
+
}
|
|
58693
58701
|
|
|
58694
|
-
|
|
58695
|
-
|
|
58696
|
-
|
|
58702
|
+
/**
|
|
58703
|
+
* Check whether an attribute has a substring as either the exact value or a
|
|
58704
|
+
* prefix.
|
|
58705
|
+
*
|
|
58706
|
+
* `[attr|=value]`
|
|
58707
|
+
*
|
|
58708
|
+
* @param {RuleAttr} query
|
|
58709
|
+
* @param {Element} element
|
|
58710
|
+
* @param {Info} info
|
|
58711
|
+
* @returns {boolean}
|
|
58712
|
+
*/
|
|
58713
|
+
function exactOrPrefix(query, element, info) {
|
|
58714
|
+
const value = normalizeValue(
|
|
58715
|
+
element.properties && element.properties[info.property],
|
|
58716
|
+
info
|
|
58717
|
+
)
|
|
58697
58718
|
|
|
58698
|
-
|
|
58719
|
+
return Boolean(
|
|
58720
|
+
hasProperty(element, info.property) &&
|
|
58721
|
+
query.value &&
|
|
58722
|
+
(value === query.value ||
|
|
58723
|
+
(value.slice(0, query.value.length) === query.value &&
|
|
58724
|
+
value.charAt(query.value.length) === '-'))
|
|
58725
|
+
)
|
|
58726
|
+
}
|
|
58699
58727
|
|
|
58700
|
-
|
|
58701
|
-
|
|
58728
|
+
/**
|
|
58729
|
+
* Check whether an attribute has a substring as its start.
|
|
58730
|
+
*
|
|
58731
|
+
* `[attr^=value]`
|
|
58732
|
+
*
|
|
58733
|
+
* @param {RuleAttr} query
|
|
58734
|
+
* @param {Element} element
|
|
58735
|
+
* @param {Info} info
|
|
58736
|
+
* @returns {boolean}
|
|
58737
|
+
*/
|
|
58738
|
+
function begins(query, element, info) {
|
|
58739
|
+
return Boolean(
|
|
58740
|
+
hasProperty(element, info.property) &&
|
|
58741
|
+
element.properties &&
|
|
58742
|
+
query.value &&
|
|
58743
|
+
normalizeValue(element.properties[info.property], info).slice(
|
|
58744
|
+
0,
|
|
58745
|
+
query.value.length
|
|
58746
|
+
) === query.value
|
|
58747
|
+
)
|
|
58702
58748
|
}
|
|
58703
58749
|
|
|
58704
|
-
/**
|
|
58705
|
-
|
|
58706
|
-
|
|
58707
|
-
|
|
58708
|
-
|
|
58750
|
+
/**
|
|
58751
|
+
* Check whether an attribute has a substring as its end.
|
|
58752
|
+
*
|
|
58753
|
+
* `[attr$=value]`
|
|
58754
|
+
*
|
|
58755
|
+
* @param {RuleAttr} query
|
|
58756
|
+
* @param {Element} element
|
|
58757
|
+
* @param {Info} info
|
|
58758
|
+
* @returns {boolean}
|
|
58759
|
+
*/
|
|
58760
|
+
function ends(query, element, info) {
|
|
58761
|
+
return Boolean(
|
|
58762
|
+
hasProperty(element, info.property) &&
|
|
58763
|
+
element.properties &&
|
|
58764
|
+
query.value &&
|
|
58765
|
+
normalizeValue(element.properties[info.property], info).slice(
|
|
58766
|
+
-query.value.length
|
|
58767
|
+
) === query.value
|
|
58768
|
+
)
|
|
58709
58769
|
}
|
|
58710
58770
|
|
|
58711
|
-
/**
|
|
58712
|
-
|
|
58713
|
-
|
|
58714
|
-
|
|
58715
|
-
|
|
58716
|
-
|
|
58771
|
+
/**
|
|
58772
|
+
* Check whether an attribute contains a substring.
|
|
58773
|
+
*
|
|
58774
|
+
* `[attr*=value]`
|
|
58775
|
+
*
|
|
58776
|
+
* @param {RuleAttr} query
|
|
58777
|
+
* @param {Element} element
|
|
58778
|
+
* @param {Info} info
|
|
58779
|
+
* @returns {boolean}
|
|
58780
|
+
*/
|
|
58781
|
+
function contains(query, element, info) {
|
|
58782
|
+
return Boolean(
|
|
58783
|
+
hasProperty(element, info.property) &&
|
|
58784
|
+
element.properties &&
|
|
58785
|
+
query.value &&
|
|
58786
|
+
normalizeValue(element.properties[info.property], info).includes(
|
|
58787
|
+
query.value
|
|
58788
|
+
)
|
|
58789
|
+
)
|
|
58717
58790
|
}
|
|
58718
58791
|
|
|
58719
|
-
|
|
58720
|
-
|
|
58721
|
-
|
|
58722
|
-
|
|
58723
|
-
|
|
58724
|
-
|
|
58792
|
+
// Shouldn’t be called, Parser throws an error instead.
|
|
58793
|
+
/**
|
|
58794
|
+
* @param {unknown} query
|
|
58795
|
+
* @returns {never}
|
|
58796
|
+
*/
|
|
58797
|
+
/* c8 ignore next 4 */
|
|
58798
|
+
function unknownOperator(query) {
|
|
58799
|
+
// @ts-expect-error: `operator` guaranteed.
|
|
58800
|
+
throw new Error('Unknown operator `' + query.operator + '`')
|
|
58725
58801
|
}
|
|
58726
58802
|
|
|
58727
58803
|
/**
|
|
58728
|
-
*
|
|
58804
|
+
* Stringify a hast value back to its HTML form.
|
|
58729
58805
|
*
|
|
58730
|
-
* @param {
|
|
58731
|
-
* @param {
|
|
58732
|
-
* @
|
|
58733
|
-
* @param {number} [from=0]
|
|
58734
|
-
* @param {boolean} [firstElementOnly=false]
|
|
58806
|
+
* @param {PropertyValue} value
|
|
58807
|
+
* @param {Info} info
|
|
58808
|
+
* @returns {string}
|
|
58735
58809
|
*/
|
|
58736
|
-
function
|
|
58737
|
-
|
|
58738
|
-
|
|
58739
|
-
let elements = 0
|
|
58740
|
-
let index = -1
|
|
58741
|
-
/** @type {Record<string, number>} */
|
|
58742
|
-
const types = {}
|
|
58743
|
-
/** @type {Array<Function>} */
|
|
58744
|
-
const delayed = []
|
|
58745
|
-
|
|
58746
|
-
// Start looking at `from`
|
|
58747
|
-
if (from === undefined || from === null) from = 0
|
|
58748
|
-
|
|
58749
|
-
// Exit if there are no further nodes.
|
|
58750
|
-
if (from >= children.length) return
|
|
58751
|
-
|
|
58752
|
-
// If we need to index for types, do so for all elements before `from`.
|
|
58753
|
-
if (state.index) {
|
|
58754
|
-
while (++index < from) {
|
|
58755
|
-
const child = children[index]
|
|
58756
|
-
if (util_element(child)) count(child.tagName)
|
|
58757
|
-
}
|
|
58758
|
-
}
|
|
58759
|
-
|
|
58760
|
-
index = from - 1
|
|
58761
|
-
|
|
58762
|
-
while (++index < children.length) {
|
|
58763
|
-
const child = children[index]
|
|
58764
|
-
// Only check elements.
|
|
58765
|
-
// Check either all elements, or only check the first sibling
|
|
58766
|
-
if (util_element(child)) {
|
|
58767
|
-
handle(child, index)
|
|
58768
|
-
|
|
58769
|
-
// Stop if we’re looking for one node and it’s already found.
|
|
58770
|
-
if (state.one && state.found) return
|
|
58771
|
-
if (firstElementOnly) break
|
|
58772
|
-
}
|
|
58810
|
+
function normalizeValue(value, info) {
|
|
58811
|
+
if (typeof value === 'boolean') {
|
|
58812
|
+
return info.attribute
|
|
58773
58813
|
}
|
|
58774
58814
|
|
|
58775
|
-
if (
|
|
58776
|
-
|
|
58777
|
-
|
|
58778
|
-
while (++index < delayed.length) {
|
|
58779
|
-
delayed[index]()
|
|
58780
|
-
if (state.one && state.found) return
|
|
58781
|
-
}
|
|
58815
|
+
if (Array.isArray(value)) {
|
|
58816
|
+
return (info.commaSeparated ? comma_separated_tokens_stringify : stringify)(value)
|
|
58782
58817
|
}
|
|
58783
58818
|
|
|
58784
|
-
|
|
58785
|
-
|
|
58786
|
-
* @param {number} childIndex
|
|
58787
|
-
*/
|
|
58788
|
-
function delay(node, childIndex) {
|
|
58789
|
-
const elementsBefore = elements
|
|
58790
|
-
const elementsByTypeBefore = nest_own.call(types, node.tagName)
|
|
58791
|
-
? types[node.tagName]
|
|
58792
|
-
: 0
|
|
58793
|
-
|
|
58794
|
-
count(node.tagName)
|
|
58795
|
-
|
|
58796
|
-
delayed.push(fn)
|
|
58819
|
+
return String(value)
|
|
58820
|
+
}
|
|
58797
58821
|
|
|
58798
|
-
|
|
58799
|
-
|
|
58800
|
-
|
|
58801
|
-
|
|
58822
|
+
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/class-name.js
|
|
58823
|
+
/**
|
|
58824
|
+
* @typedef {import('./types.js').Rule} Rule
|
|
58825
|
+
* @typedef {import('./types.js').Element} Element
|
|
58826
|
+
*/
|
|
58802
58827
|
|
|
58803
|
-
|
|
58804
|
-
|
|
58805
|
-
|
|
58828
|
+
/**
|
|
58829
|
+
* Check whether an element has all class names.
|
|
58830
|
+
*
|
|
58831
|
+
* @param {Rule} query
|
|
58832
|
+
* @param {Element} element
|
|
58833
|
+
* @returns {boolean}
|
|
58834
|
+
*/
|
|
58835
|
+
function className(query, element) {
|
|
58836
|
+
/** @type {readonly string[]} */
|
|
58837
|
+
// @ts-expect-error Assume array.
|
|
58838
|
+
const value = element.properties.className || []
|
|
58839
|
+
let index = -1
|
|
58806
58840
|
|
|
58807
|
-
|
|
58841
|
+
if (query.classNames) {
|
|
58842
|
+
while (++index < query.classNames.length) {
|
|
58843
|
+
if (!value.includes(query.classNames[index])) return false
|
|
58808
58844
|
}
|
|
58809
58845
|
}
|
|
58810
58846
|
|
|
58811
|
-
|
|
58812
|
-
|
|
58813
|
-
* @param {number} childIndex
|
|
58814
|
-
*/
|
|
58815
|
-
function add(node, childIndex) {
|
|
58816
|
-
const exit = enterState(state, node)
|
|
58847
|
+
return true
|
|
58848
|
+
}
|
|
58817
58849
|
|
|
58818
|
-
|
|
58819
|
-
|
|
58820
|
-
|
|
58821
|
-
|
|
58822
|
-
|
|
58850
|
+
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/id.js
|
|
58851
|
+
/**
|
|
58852
|
+
* @typedef {import('./types.js').Rule} Rule
|
|
58853
|
+
* @typedef {import('./types.js').Element} Element
|
|
58854
|
+
*/
|
|
58823
58855
|
|
|
58824
|
-
|
|
58825
|
-
|
|
58826
|
-
|
|
58856
|
+
/**
|
|
58857
|
+
* Check whether an element has an ID.
|
|
58858
|
+
*
|
|
58859
|
+
* @param {Rule} query
|
|
58860
|
+
* @param {Element} element
|
|
58861
|
+
* @returns {boolean}
|
|
58862
|
+
*/
|
|
58863
|
+
function id(query, element) {
|
|
58864
|
+
return Boolean(element.properties && element.properties.id === query.id)
|
|
58865
|
+
}
|
|
58827
58866
|
|
|
58828
|
-
|
|
58829
|
-
|
|
58830
|
-
|
|
58831
|
-
|
|
58832
|
-
|
|
58833
|
-
|
|
58834
|
-
|
|
58835
|
-
|
|
58867
|
+
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/name.js
|
|
58868
|
+
/**
|
|
58869
|
+
* @typedef {import('./types.js').Rule} Rule
|
|
58870
|
+
* @typedef {import('./types.js').Element} Element
|
|
58871
|
+
*/
|
|
58872
|
+
|
|
58873
|
+
/**
|
|
58874
|
+
* Check whether an element has a tag name.
|
|
58875
|
+
*
|
|
58876
|
+
* @param {Rule} query
|
|
58877
|
+
* @param {Element} element
|
|
58878
|
+
* @returns {boolean}
|
|
58879
|
+
*/
|
|
58880
|
+
function name_name(query, element) {
|
|
58881
|
+
return query.tagName === '*' || query.tagName === element.tagName
|
|
58836
58882
|
}
|
|
58837
58883
|
|
|
58838
58884
|
;// CONCATENATED MODULE: ../node_modules/bcp-47-match/index.js
|
|
@@ -59071,15 +59117,266 @@ function cast(values, name) {
|
|
|
59071
59117
|
return value
|
|
59072
59118
|
}
|
|
59073
59119
|
|
|
59120
|
+
;// CONCATENATED MODULE: ../node_modules/nth-check/lib/esm/parse.js
|
|
59121
|
+
// Following http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
|
|
59122
|
+
// Whitespace as per https://www.w3.org/TR/selectors-3/#lex is " \t\r\n\f"
|
|
59123
|
+
const parse_whitespace = new Set([9, 10, 12, 13, 32]);
|
|
59124
|
+
const ZERO = "0".charCodeAt(0);
|
|
59125
|
+
const NINE = "9".charCodeAt(0);
|
|
59126
|
+
/**
|
|
59127
|
+
* Parses an expression.
|
|
59128
|
+
*
|
|
59129
|
+
* @throws An `Error` if parsing fails.
|
|
59130
|
+
* @returns An array containing the integer step size and the integer offset of the nth rule.
|
|
59131
|
+
* @example nthCheck.parse("2n+3"); // returns [2, 3]
|
|
59132
|
+
*/
|
|
59133
|
+
function esm_parse_parse(formula) {
|
|
59134
|
+
formula = formula.trim().toLowerCase();
|
|
59135
|
+
if (formula === "even") {
|
|
59136
|
+
return [2, 0];
|
|
59137
|
+
}
|
|
59138
|
+
else if (formula === "odd") {
|
|
59139
|
+
return [2, 1];
|
|
59140
|
+
}
|
|
59141
|
+
// Parse [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]?
|
|
59142
|
+
let idx = 0;
|
|
59143
|
+
let a = 0;
|
|
59144
|
+
let sign = readSign();
|
|
59145
|
+
let number = readNumber();
|
|
59146
|
+
if (idx < formula.length && formula.charAt(idx) === "n") {
|
|
59147
|
+
idx++;
|
|
59148
|
+
a = sign * (number !== null && number !== void 0 ? number : 1);
|
|
59149
|
+
skipWhitespace();
|
|
59150
|
+
if (idx < formula.length) {
|
|
59151
|
+
sign = readSign();
|
|
59152
|
+
skipWhitespace();
|
|
59153
|
+
number = readNumber();
|
|
59154
|
+
}
|
|
59155
|
+
else {
|
|
59156
|
+
sign = number = 0;
|
|
59157
|
+
}
|
|
59158
|
+
}
|
|
59159
|
+
// Throw if there is anything else
|
|
59160
|
+
if (number === null || idx < formula.length) {
|
|
59161
|
+
throw new Error(`n-th rule couldn't be parsed ('${formula}')`);
|
|
59162
|
+
}
|
|
59163
|
+
return [a, sign * number];
|
|
59164
|
+
function readSign() {
|
|
59165
|
+
if (formula.charAt(idx) === "-") {
|
|
59166
|
+
idx++;
|
|
59167
|
+
return -1;
|
|
59168
|
+
}
|
|
59169
|
+
if (formula.charAt(idx) === "+") {
|
|
59170
|
+
idx++;
|
|
59171
|
+
}
|
|
59172
|
+
return 1;
|
|
59173
|
+
}
|
|
59174
|
+
function readNumber() {
|
|
59175
|
+
const start = idx;
|
|
59176
|
+
let value = 0;
|
|
59177
|
+
while (idx < formula.length &&
|
|
59178
|
+
formula.charCodeAt(idx) >= ZERO &&
|
|
59179
|
+
formula.charCodeAt(idx) <= NINE) {
|
|
59180
|
+
value = value * 10 + (formula.charCodeAt(idx) - ZERO);
|
|
59181
|
+
idx++;
|
|
59182
|
+
}
|
|
59183
|
+
// Return `null` if we didn't read anything.
|
|
59184
|
+
return idx === start ? null : value;
|
|
59185
|
+
}
|
|
59186
|
+
function skipWhitespace() {
|
|
59187
|
+
while (idx < formula.length &&
|
|
59188
|
+
parse_whitespace.has(formula.charCodeAt(idx))) {
|
|
59189
|
+
idx++;
|
|
59190
|
+
}
|
|
59191
|
+
}
|
|
59192
|
+
}
|
|
59193
|
+
//# sourceMappingURL=parse.js.map
|
|
59194
|
+
// EXTERNAL MODULE: ../node_modules/boolbase/index.js
|
|
59195
|
+
var boolbase = __webpack_require__(286);
|
|
59196
|
+
;// CONCATENATED MODULE: ../node_modules/nth-check/lib/esm/compile.js
|
|
59197
|
+
|
|
59198
|
+
/**
|
|
59199
|
+
* Returns a function that checks if an elements index matches the given rule
|
|
59200
|
+
* highly optimized to return the fastest solution.
|
|
59201
|
+
*
|
|
59202
|
+
* @param parsed A tuple [a, b], as returned by `parse`.
|
|
59203
|
+
* @returns A highly optimized function that returns whether an index matches the nth-check.
|
|
59204
|
+
* @example
|
|
59205
|
+
*
|
|
59206
|
+
* ```js
|
|
59207
|
+
* const check = nthCheck.compile([2, 3]);
|
|
59208
|
+
*
|
|
59209
|
+
* check(0); // `false`
|
|
59210
|
+
* check(1); // `false`
|
|
59211
|
+
* check(2); // `true`
|
|
59212
|
+
* check(3); // `false`
|
|
59213
|
+
* check(4); // `true`
|
|
59214
|
+
* check(5); // `false`
|
|
59215
|
+
* check(6); // `true`
|
|
59216
|
+
* ```
|
|
59217
|
+
*/
|
|
59218
|
+
function compile(parsed) {
|
|
59219
|
+
const a = parsed[0];
|
|
59220
|
+
// Subtract 1 from `b`, to convert from one- to zero-indexed.
|
|
59221
|
+
const b = parsed[1] - 1;
|
|
59222
|
+
/*
|
|
59223
|
+
* When `b <= 0`, `a * n` won't be lead to any matches for `a < 0`.
|
|
59224
|
+
* Besides, the specification states that no elements are
|
|
59225
|
+
* matched when `a` and `b` are 0.
|
|
59226
|
+
*
|
|
59227
|
+
* `b < 0` here as we subtracted 1 from `b` above.
|
|
59228
|
+
*/
|
|
59229
|
+
if (b < 0 && a <= 0)
|
|
59230
|
+
return boolbase.falseFunc;
|
|
59231
|
+
// When `a` is in the range -1..1, it matches any element (so only `b` is checked).
|
|
59232
|
+
if (a === -1)
|
|
59233
|
+
return (index) => index <= b;
|
|
59234
|
+
if (a === 0)
|
|
59235
|
+
return (index) => index === b;
|
|
59236
|
+
// When `b <= 0` and `a === 1`, they match any element.
|
|
59237
|
+
if (a === 1)
|
|
59238
|
+
return b < 0 ? boolbase.trueFunc : (index) => index >= b;
|
|
59239
|
+
/*
|
|
59240
|
+
* Otherwise, modulo can be used to check if there is a match.
|
|
59241
|
+
*
|
|
59242
|
+
* Modulo doesn't care about the sign, so let's use `a`s absolute value.
|
|
59243
|
+
*/
|
|
59244
|
+
const absA = Math.abs(a);
|
|
59245
|
+
// Get `b mod a`, + a if this is negative.
|
|
59246
|
+
const bMod = ((b % absA) + absA) % absA;
|
|
59247
|
+
return a > 1
|
|
59248
|
+
? (index) => index >= b && index % absA === bMod
|
|
59249
|
+
: (index) => index <= b && index % absA === bMod;
|
|
59250
|
+
}
|
|
59251
|
+
/**
|
|
59252
|
+
* Returns a function that produces a monotonously increasing sequence of indices.
|
|
59253
|
+
*
|
|
59254
|
+
* If the sequence has an end, the returned function will return `null` after
|
|
59255
|
+
* the last index in the sequence.
|
|
59256
|
+
*
|
|
59257
|
+
* @param parsed A tuple [a, b], as returned by `parse`.
|
|
59258
|
+
* @returns A function that produces a sequence of indices.
|
|
59259
|
+
* @example <caption>Always increasing (2n+3)</caption>
|
|
59260
|
+
*
|
|
59261
|
+
* ```js
|
|
59262
|
+
* const gen = nthCheck.generate([2, 3])
|
|
59263
|
+
*
|
|
59264
|
+
* gen() // `1`
|
|
59265
|
+
* gen() // `3`
|
|
59266
|
+
* gen() // `5`
|
|
59267
|
+
* gen() // `8`
|
|
59268
|
+
* gen() // `11`
|
|
59269
|
+
* ```
|
|
59270
|
+
*
|
|
59271
|
+
* @example <caption>With end value (-2n+10)</caption>
|
|
59272
|
+
*
|
|
59273
|
+
* ```js
|
|
59274
|
+
*
|
|
59275
|
+
* const gen = nthCheck.generate([-2, 5]);
|
|
59276
|
+
*
|
|
59277
|
+
* gen() // 0
|
|
59278
|
+
* gen() // 2
|
|
59279
|
+
* gen() // 4
|
|
59280
|
+
* gen() // null
|
|
59281
|
+
* ```
|
|
59282
|
+
*/
|
|
59283
|
+
function compile_generate(parsed) {
|
|
59284
|
+
const a = parsed[0];
|
|
59285
|
+
// Subtract 1 from `b`, to convert from one- to zero-indexed.
|
|
59286
|
+
let b = parsed[1] - 1;
|
|
59287
|
+
let n = 0;
|
|
59288
|
+
// Make sure to always return an increasing sequence
|
|
59289
|
+
if (a < 0) {
|
|
59290
|
+
const aPos = -a;
|
|
59291
|
+
// Get `b mod a`
|
|
59292
|
+
const minValue = ((b % aPos) + aPos) % aPos;
|
|
59293
|
+
return () => {
|
|
59294
|
+
const val = minValue + aPos * n++;
|
|
59295
|
+
return val > b ? null : val;
|
|
59296
|
+
};
|
|
59297
|
+
}
|
|
59298
|
+
if (a === 0)
|
|
59299
|
+
return b < 0
|
|
59300
|
+
? // There are no result — always return `null`
|
|
59301
|
+
() => null
|
|
59302
|
+
: // Return `b` exactly once
|
|
59303
|
+
() => (n++ === 0 ? b : null);
|
|
59304
|
+
if (b < 0) {
|
|
59305
|
+
b += a * Math.ceil(-b / a);
|
|
59306
|
+
}
|
|
59307
|
+
return () => a * n++ + b;
|
|
59308
|
+
}
|
|
59309
|
+
//# sourceMappingURL=compile.js.map
|
|
59310
|
+
;// CONCATENATED MODULE: ../node_modules/nth-check/lib/esm/index.js
|
|
59311
|
+
|
|
59312
|
+
|
|
59313
|
+
|
|
59314
|
+
/**
|
|
59315
|
+
* Parses and compiles a formula to a highly optimized function.
|
|
59316
|
+
* Combination of {@link parse} and {@link compile}.
|
|
59317
|
+
*
|
|
59318
|
+
* If the formula doesn't match any elements,
|
|
59319
|
+
* it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
|
|
59320
|
+
* Otherwise, a function accepting an _index_ is returned, which returns
|
|
59321
|
+
* whether or not the passed _index_ matches the formula.
|
|
59322
|
+
*
|
|
59323
|
+
* Note: The nth-rule starts counting at `1`, the returned function at `0`.
|
|
59324
|
+
*
|
|
59325
|
+
* @param formula The formula to compile.
|
|
59326
|
+
* @example
|
|
59327
|
+
* const check = nthCheck("2n+3");
|
|
59328
|
+
*
|
|
59329
|
+
* check(0); // `false`
|
|
59330
|
+
* check(1); // `false`
|
|
59331
|
+
* check(2); // `true`
|
|
59332
|
+
* check(3); // `false`
|
|
59333
|
+
* check(4); // `true`
|
|
59334
|
+
* check(5); // `false`
|
|
59335
|
+
* check(6); // `true`
|
|
59336
|
+
*/
|
|
59337
|
+
function nthCheck(formula) {
|
|
59338
|
+
return compile(esm_parse_parse(formula));
|
|
59339
|
+
}
|
|
59340
|
+
/**
|
|
59341
|
+
* Parses and compiles a formula to a generator that produces a sequence of indices.
|
|
59342
|
+
* Combination of {@link parse} and {@link generate}.
|
|
59343
|
+
*
|
|
59344
|
+
* @param formula The formula to compile.
|
|
59345
|
+
* @returns A function that produces a sequence of indices.
|
|
59346
|
+
* @example <caption>Always increasing</caption>
|
|
59347
|
+
*
|
|
59348
|
+
* ```js
|
|
59349
|
+
* const gen = nthCheck.sequence('2n+3')
|
|
59350
|
+
*
|
|
59351
|
+
* gen() // `1`
|
|
59352
|
+
* gen() // `3`
|
|
59353
|
+
* gen() // `5`
|
|
59354
|
+
* gen() // `8`
|
|
59355
|
+
* gen() // `11`
|
|
59356
|
+
* ```
|
|
59357
|
+
*
|
|
59358
|
+
* @example <caption>With end value</caption>
|
|
59359
|
+
*
|
|
59360
|
+
* ```js
|
|
59361
|
+
*
|
|
59362
|
+
* const gen = nthCheck.sequence('-2n+5');
|
|
59363
|
+
*
|
|
59364
|
+
* gen() // 0
|
|
59365
|
+
* gen() // 2
|
|
59366
|
+
* gen() // 4
|
|
59367
|
+
* gen() // null
|
|
59368
|
+
* ```
|
|
59369
|
+
*/
|
|
59370
|
+
function sequence(formula) {
|
|
59371
|
+
return generate(parse(formula));
|
|
59372
|
+
}
|
|
59373
|
+
//# sourceMappingURL=index.js.map
|
|
59074
59374
|
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/pseudo.js
|
|
59075
59375
|
/**
|
|
59076
59376
|
* @typedef {import('./types.js').Rule} Rule
|
|
59077
59377
|
* @typedef {import('./types.js').RulePseudo} RulePseudo
|
|
59078
|
-
* @typedef {import('./types.js').RulePseudoNth} RulePseudoNth
|
|
59079
59378
|
* @typedef {import('./types.js').RulePseudoSelector} RulePseudoSelector
|
|
59080
59379
|
* @typedef {import('./types.js').Parent} Parent
|
|
59081
|
-
* @typedef {import('./types.js').Selector} Selector
|
|
59082
|
-
* @typedef {import('./types.js').Selectors} Selectors
|
|
59083
59380
|
* @typedef {import('./types.js').SelectState} SelectState
|
|
59084
59381
|
* @typedef {import('./types.js').Element} Element
|
|
59085
59382
|
* @typedef {import('./types.js').ElementChild} ElementChild
|
|
@@ -59093,75 +59390,54 @@ function cast(values, name) {
|
|
|
59093
59390
|
|
|
59094
59391
|
|
|
59095
59392
|
|
|
59393
|
+
/** @type {import('nth-check').default} */
|
|
59394
|
+
// @ts-expect-error
|
|
59395
|
+
const pseudo_nthCheck = nthCheck["default"] || nthCheck
|
|
59396
|
+
|
|
59397
|
+
/** @type {(rule: Rule | RulePseudo, element: Element, index: number | undefined, parent: Parent | undefined, state: SelectState) => boolean} */
|
|
59096
59398
|
const pseudo_handle = zwitch('name', {
|
|
59097
|
-
// @ts-expect-error: hush.
|
|
59098
59399
|
unknown: unknownPseudo,
|
|
59099
59400
|
invalid: invalidPseudo,
|
|
59100
59401
|
handlers: {
|
|
59101
|
-
// @ts-expect-error: hush.
|
|
59102
59402
|
any: matches,
|
|
59103
|
-
// @ts-expect-error: hush.
|
|
59104
59403
|
'any-link': anyLink,
|
|
59105
|
-
// @ts-expect-error: hush.
|
|
59106
59404
|
blank,
|
|
59107
|
-
// @ts-expect-error: hush.
|
|
59108
59405
|
checked,
|
|
59109
|
-
// @ts-expect-error: hush.
|
|
59110
59406
|
dir,
|
|
59111
|
-
// @ts-expect-error: hush.
|
|
59112
59407
|
disabled,
|
|
59113
|
-
// @ts-expect-error: hush.
|
|
59114
59408
|
empty,
|
|
59115
|
-
// @ts-expect-error: hush.
|
|
59116
59409
|
enabled,
|
|
59117
|
-
// @ts-expect-error: hush.
|
|
59118
59410
|
'first-child': firstChild,
|
|
59119
|
-
// @ts-expect-error: hush.
|
|
59120
59411
|
'first-of-type': firstOfType,
|
|
59121
|
-
// @ts-expect-error: hush.
|
|
59122
59412
|
has,
|
|
59123
|
-
// @ts-expect-error: hush.
|
|
59124
59413
|
lang: pseudo_lang,
|
|
59125
|
-
// @ts-expect-error: hush.
|
|
59126
59414
|
'last-child': lastChild,
|
|
59127
|
-
// @ts-expect-error: hush.
|
|
59128
59415
|
'last-of-type': lastOfType,
|
|
59129
|
-
// @ts-expect-error: hush.
|
|
59130
59416
|
matches,
|
|
59131
|
-
// @ts-expect-error: hush.
|
|
59132
59417
|
not,
|
|
59133
|
-
// @ts-expect-error: hush.
|
|
59134
59418
|
'nth-child': nthChild,
|
|
59135
|
-
// @ts-expect-error: hush.
|
|
59136
59419
|
'nth-last-child': nthLastChild,
|
|
59137
|
-
// @ts-expect-error: hush.
|
|
59138
59420
|
'nth-of-type': nthOfType,
|
|
59139
|
-
// @ts-expect-error: hush.
|
|
59140
59421
|
'nth-last-of-type': nthLastOfType,
|
|
59141
|
-
// @ts-expect-error: hush.
|
|
59142
59422
|
'only-child': onlyChild,
|
|
59143
|
-
// @ts-expect-error: hush.
|
|
59144
59423
|
'only-of-type': onlyOfType,
|
|
59145
|
-
// @ts-expect-error: hush.
|
|
59146
59424
|
optional,
|
|
59147
|
-
// @ts-expect-error: hush.
|
|
59148
59425
|
'read-only': readOnly,
|
|
59149
|
-
// @ts-expect-error: hush.
|
|
59150
59426
|
'read-write': readWrite,
|
|
59151
|
-
// @ts-expect-error: hush.
|
|
59152
59427
|
required,
|
|
59153
|
-
// @ts-expect-error: hush.
|
|
59154
59428
|
root: pseudo_root,
|
|
59155
|
-
// @ts-expect-error: hush.
|
|
59156
59429
|
scope
|
|
59157
59430
|
}
|
|
59158
59431
|
})
|
|
59159
59432
|
|
|
59160
59433
|
pseudo.needsIndex = [
|
|
59434
|
+
'any',
|
|
59161
59435
|
'first-child',
|
|
59162
59436
|
'first-of-type',
|
|
59163
59437
|
'last-child',
|
|
59164
59438
|
'last-of-type',
|
|
59439
|
+
'matches',
|
|
59440
|
+
'not',
|
|
59165
59441
|
'nth-child',
|
|
59166
59442
|
'nth-last-child',
|
|
59167
59443
|
'nth-of-type',
|
|
@@ -59171,10 +59447,12 @@ pseudo.needsIndex = [
|
|
|
59171
59447
|
]
|
|
59172
59448
|
|
|
59173
59449
|
/**
|
|
59450
|
+
* Check whether an element matches pseudo selectors.
|
|
59451
|
+
*
|
|
59174
59452
|
* @param {Rule} query
|
|
59175
59453
|
* @param {Element} element
|
|
59176
|
-
* @param {number|
|
|
59177
|
-
* @param {Parent|
|
|
59454
|
+
* @param {number | undefined} index
|
|
59455
|
+
* @param {Parent | undefined} parent
|
|
59178
59456
|
* @param {SelectState} state
|
|
59179
59457
|
* @returns {boolean}
|
|
59180
59458
|
*/
|
|
@@ -59190,58 +59468,51 @@ function pseudo(query, element, index, parent, state) {
|
|
|
59190
59468
|
}
|
|
59191
59469
|
|
|
59192
59470
|
/**
|
|
59193
|
-
*
|
|
59194
|
-
*
|
|
59195
|
-
* @param {
|
|
59196
|
-
* @param {Parent|null} _2
|
|
59197
|
-
* @param {SelectState} state
|
|
59198
|
-
* @returns {boolean}
|
|
59199
|
-
*/
|
|
59200
|
-
function matches(query, element, _1, _2, state) {
|
|
59201
|
-
const shallow = state.shallow
|
|
59202
|
-
const one = state.one
|
|
59203
|
-
|
|
59204
|
-
state.shallow = true
|
|
59205
|
-
state.one = true
|
|
59206
|
-
|
|
59207
|
-
const result = any_any(query.value, element, state)[0] === element
|
|
59208
|
-
|
|
59209
|
-
state.shallow = shallow
|
|
59210
|
-
state.one = one
|
|
59211
|
-
|
|
59212
|
-
return result
|
|
59213
|
-
}
|
|
59214
|
-
|
|
59215
|
-
/**
|
|
59216
|
-
* @param {RulePseudoSelector} query
|
|
59471
|
+
* Check whether an element matches an `:any-link` pseudo.
|
|
59472
|
+
*
|
|
59473
|
+
* @param {RulePseudo} _
|
|
59217
59474
|
* @param {Element} element
|
|
59218
|
-
* @param {number|null} index
|
|
59219
|
-
* @param {Parent|null} parent
|
|
59220
|
-
* @param {SelectState} state
|
|
59221
59475
|
* @returns {boolean}
|
|
59222
59476
|
*/
|
|
59223
|
-
function
|
|
59224
|
-
return
|
|
59477
|
+
function anyLink(_, element) {
|
|
59478
|
+
return (
|
|
59479
|
+
(element.tagName === 'a' ||
|
|
59480
|
+
element.tagName === 'area' ||
|
|
59481
|
+
element.tagName === 'link') &&
|
|
59482
|
+
hasProperty(element, 'href')
|
|
59483
|
+
)
|
|
59225
59484
|
}
|
|
59226
59485
|
|
|
59227
59486
|
/**
|
|
59487
|
+
* Check whether an element matches a `:blank` pseudo.
|
|
59488
|
+
*
|
|
59228
59489
|
* @param {RulePseudo} _
|
|
59229
59490
|
* @param {Element} element
|
|
59230
59491
|
* @returns {boolean}
|
|
59231
59492
|
*/
|
|
59232
|
-
function
|
|
59233
|
-
return (
|
|
59234
|
-
|
|
59235
|
-
|
|
59493
|
+
function blank(_, element) {
|
|
59494
|
+
return !someChildren(element, check)
|
|
59495
|
+
|
|
59496
|
+
/**
|
|
59497
|
+
* @param {ElementChild} child
|
|
59498
|
+
* @returns {boolean}
|
|
59499
|
+
*/
|
|
59500
|
+
function check(child) {
|
|
59501
|
+
return (
|
|
59502
|
+
child.type === 'element' || (child.type === 'text' && !whitespace(child))
|
|
59503
|
+
)
|
|
59504
|
+
}
|
|
59236
59505
|
}
|
|
59237
59506
|
|
|
59238
59507
|
/**
|
|
59508
|
+
* Check whether an element matches a `:checked` pseudo.
|
|
59509
|
+
*
|
|
59239
59510
|
* @param {RulePseudo} _
|
|
59240
59511
|
* @param {Element} element
|
|
59241
59512
|
* @returns {boolean}
|
|
59242
59513
|
*/
|
|
59243
59514
|
function checked(_, element) {
|
|
59244
|
-
if (
|
|
59515
|
+
if (element.tagName === 'input' || element.tagName === 'menuitem') {
|
|
59245
59516
|
return Boolean(
|
|
59246
59517
|
element.properties &&
|
|
59247
59518
|
(element.properties.type === 'checkbox' ||
|
|
@@ -59250,7 +59521,7 @@ function checked(_, element) {
|
|
|
59250
59521
|
)
|
|
59251
59522
|
}
|
|
59252
59523
|
|
|
59253
|
-
if (
|
|
59524
|
+
if (element.tagName === 'option') {
|
|
59254
59525
|
return hasProperty(element, 'selected')
|
|
59255
59526
|
}
|
|
59256
59527
|
|
|
@@ -59258,10 +59529,12 @@ function checked(_, element) {
|
|
|
59258
59529
|
}
|
|
59259
59530
|
|
|
59260
59531
|
/**
|
|
59532
|
+
* Check whether an element matches a `:dir()` pseudo.
|
|
59533
|
+
*
|
|
59261
59534
|
* @param {RulePseudo} query
|
|
59262
59535
|
* @param {Element} _1
|
|
59263
|
-
* @param {number|
|
|
59264
|
-
* @param {Parent|
|
|
59536
|
+
* @param {number | undefined} _2
|
|
59537
|
+
* @param {Parent | undefined} _3
|
|
59265
59538
|
* @param {SelectState} state
|
|
59266
59539
|
* @returns {boolean}
|
|
59267
59540
|
*/
|
|
@@ -59270,168 +59543,119 @@ function dir(query, _1, _2, _3, state) {
|
|
|
59270
59543
|
}
|
|
59271
59544
|
|
|
59272
59545
|
/**
|
|
59546
|
+
* Check whether an element matches a `:disabled` pseudo.
|
|
59547
|
+
*
|
|
59273
59548
|
* @param {RulePseudo} _
|
|
59274
59549
|
* @param {Element} element
|
|
59275
59550
|
* @returns {boolean}
|
|
59276
59551
|
*/
|
|
59277
59552
|
function disabled(_, element) {
|
|
59278
59553
|
return (
|
|
59279
|
-
|
|
59280
|
-
'
|
|
59281
|
-
'
|
|
59282
|
-
'
|
|
59283
|
-
'
|
|
59284
|
-
'
|
|
59285
|
-
'
|
|
59286
|
-
'
|
|
59287
|
-
|
|
59288
|
-
]) && hasProperty(element, 'disabled')
|
|
59554
|
+
(element.tagName === 'button' ||
|
|
59555
|
+
element.tagName === 'input' ||
|
|
59556
|
+
element.tagName === 'select' ||
|
|
59557
|
+
element.tagName === 'textarea' ||
|
|
59558
|
+
element.tagName === 'optgroup' ||
|
|
59559
|
+
element.tagName === 'option' ||
|
|
59560
|
+
element.tagName === 'menuitem' ||
|
|
59561
|
+
element.tagName === 'fieldset') &&
|
|
59562
|
+
hasProperty(element, 'disabled')
|
|
59289
59563
|
)
|
|
59290
59564
|
}
|
|
59291
59565
|
|
|
59292
59566
|
/**
|
|
59293
|
-
*
|
|
59294
|
-
*
|
|
59295
|
-
* @returns {boolean}
|
|
59296
|
-
*/
|
|
59297
|
-
function enabled(query, element) {
|
|
59298
|
-
return !disabled(query, element)
|
|
59299
|
-
}
|
|
59300
|
-
|
|
59301
|
-
/**
|
|
59567
|
+
* Check whether an element matches an `:empty` pseudo.
|
|
59568
|
+
*
|
|
59302
59569
|
* @param {RulePseudo} _
|
|
59303
59570
|
* @param {Element} element
|
|
59304
59571
|
* @returns {boolean}
|
|
59305
59572
|
*/
|
|
59306
|
-
function
|
|
59307
|
-
return (
|
|
59308
|
-
isElement(element, ['input', 'textarea', 'select']) &&
|
|
59309
|
-
hasProperty(element, 'required')
|
|
59310
|
-
)
|
|
59311
|
-
}
|
|
59573
|
+
function empty(_, element) {
|
|
59574
|
+
return !someChildren(element, check)
|
|
59312
59575
|
|
|
59313
|
-
/**
|
|
59314
|
-
|
|
59315
|
-
|
|
59316
|
-
|
|
59317
|
-
|
|
59318
|
-
|
|
59319
|
-
|
|
59576
|
+
/**
|
|
59577
|
+
* @param {ElementChild} child
|
|
59578
|
+
* @returns {boolean}
|
|
59579
|
+
*/
|
|
59580
|
+
function check(child) {
|
|
59581
|
+
return child.type === 'element' || child.type === 'text'
|
|
59582
|
+
}
|
|
59320
59583
|
}
|
|
59321
59584
|
|
|
59322
59585
|
/**
|
|
59323
|
-
*
|
|
59586
|
+
* Check whether an element matches an `:enabled` pseudo.
|
|
59587
|
+
*
|
|
59588
|
+
* @param {RulePseudo} query
|
|
59324
59589
|
* @param {Element} element
|
|
59325
|
-
* @param {number|null} _1
|
|
59326
|
-
* @param {Parent|null} _2
|
|
59327
|
-
* @param {SelectState} state
|
|
59328
59590
|
* @returns {boolean}
|
|
59329
59591
|
*/
|
|
59330
|
-
function
|
|
59331
|
-
return
|
|
59332
|
-
? !hasProperty(element, 'readOnly') && !hasProperty(element, 'disabled')
|
|
59333
|
-
: Boolean(state.editableOrEditingHost)
|
|
59592
|
+
function enabled(query, element) {
|
|
59593
|
+
return !disabled(query, element)
|
|
59334
59594
|
}
|
|
59335
59595
|
|
|
59336
59596
|
/**
|
|
59597
|
+
* Check whether an element matches a `:first-child` pseudo.
|
|
59598
|
+
*
|
|
59337
59599
|
* @param {RulePseudo} query
|
|
59338
|
-
* @param {Element}
|
|
59339
|
-
* @param {number|
|
|
59340
|
-
* @param {Parent|
|
|
59600
|
+
* @param {Element} _1
|
|
59601
|
+
* @param {number | undefined} _2
|
|
59602
|
+
* @param {Parent | undefined} _3
|
|
59341
59603
|
* @param {SelectState} state
|
|
59342
59604
|
* @returns {boolean}
|
|
59343
59605
|
*/
|
|
59344
|
-
function
|
|
59345
|
-
|
|
59606
|
+
function firstChild(query, _1, _2, _3, state) {
|
|
59607
|
+
assertDeep(state, query)
|
|
59608
|
+
return state.elementIndex === 0
|
|
59346
59609
|
}
|
|
59347
59610
|
|
|
59348
59611
|
/**
|
|
59349
|
-
*
|
|
59350
|
-
*
|
|
59351
|
-
* @param {
|
|
59352
|
-
* @param {
|
|
59612
|
+
* Check whether an element matches a `:first-of-type` pseudo.
|
|
59613
|
+
*
|
|
59614
|
+
* @param {RulePseudo} query
|
|
59615
|
+
* @param {Element} _1
|
|
59616
|
+
* @param {number | undefined} _2
|
|
59617
|
+
* @param {Parent | undefined} _3
|
|
59353
59618
|
* @param {SelectState} state
|
|
59354
59619
|
* @returns {boolean}
|
|
59355
59620
|
*/
|
|
59356
|
-
function
|
|
59357
|
-
|
|
59358
|
-
|
|
59359
|
-
state.schema &&
|
|
59360
|
-
(state.schema.space === 'html' || state.schema.space === 'svg') &&
|
|
59361
|
-
isElement(element, ['html', 'svg'])
|
|
59362
|
-
)
|
|
59621
|
+
function firstOfType(query, _1, _2, _3, state) {
|
|
59622
|
+
assertDeep(state, query)
|
|
59623
|
+
return state.typeIndex === 0
|
|
59363
59624
|
}
|
|
59364
59625
|
|
|
59365
59626
|
/**
|
|
59366
|
-
* @param {
|
|
59627
|
+
* @param {RulePseudoSelector} query
|
|
59367
59628
|
* @param {Element} element
|
|
59368
|
-
* @param {number|
|
|
59369
|
-
* @param {Parent|
|
|
59629
|
+
* @param {number | undefined} _1
|
|
59630
|
+
* @param {Parent | undefined} _2
|
|
59370
59631
|
* @param {SelectState} state
|
|
59371
59632
|
* @returns {boolean}
|
|
59372
59633
|
*/
|
|
59373
|
-
function
|
|
59374
|
-
|
|
59375
|
-
|
|
59376
|
-
|
|
59377
|
-
|
|
59378
|
-
|
|
59379
|
-
|
|
59380
|
-
|
|
59381
|
-
|
|
59382
|
-
|
|
59383
|
-
|
|
59384
|
-
* @returns {boolean}
|
|
59385
|
-
*/
|
|
59386
|
-
function empty(_, element) {
|
|
59387
|
-
return !someChildren(element, check)
|
|
59388
|
-
|
|
59389
|
-
/**
|
|
59390
|
-
* @param {ElementChild} child
|
|
59391
|
-
* @returns {boolean}
|
|
59392
|
-
*/
|
|
59393
|
-
function check(child) {
|
|
59394
|
-
return child.type === 'element' || child.type === 'text'
|
|
59634
|
+
function has(query, element, _1, _2, state) {
|
|
59635
|
+
/** @type {SelectState} */
|
|
59636
|
+
const childState = {
|
|
59637
|
+
...state,
|
|
59638
|
+
// Do walk deep.
|
|
59639
|
+
shallow: false,
|
|
59640
|
+
// One result is enough.
|
|
59641
|
+
one: true,
|
|
59642
|
+
scopeElements: [element],
|
|
59643
|
+
results: [],
|
|
59644
|
+
rootQuery: queryToSelectors(query.value)
|
|
59395
59645
|
}
|
|
59396
|
-
}
|
|
59397
|
-
|
|
59398
|
-
/**
|
|
59399
|
-
* @param {RulePseudo} _
|
|
59400
|
-
* @param {Element} element
|
|
59401
|
-
* @returns {boolean}
|
|
59402
|
-
*/
|
|
59403
|
-
function blank(_, element) {
|
|
59404
|
-
return !someChildren(element, check)
|
|
59405
59646
|
|
|
59406
|
-
|
|
59407
|
-
* @param {ElementChild} child
|
|
59408
|
-
* @returns {boolean}
|
|
59409
|
-
*/
|
|
59410
|
-
function check(child) {
|
|
59411
|
-
return (
|
|
59412
|
-
child.type === 'element' || (child.type === 'text' && !whitespace(child))
|
|
59413
|
-
)
|
|
59414
|
-
}
|
|
59415
|
-
}
|
|
59647
|
+
walk_walk(childState, {type: 'root', children: element.children})
|
|
59416
59648
|
|
|
59417
|
-
|
|
59418
|
-
* @param {RulePseudo} query
|
|
59419
|
-
* @param {Element} _1
|
|
59420
|
-
* @param {number|null} _2
|
|
59421
|
-
* @param {Parent|null} _3
|
|
59422
|
-
* @param {SelectState} state
|
|
59423
|
-
* @returns {boolean}
|
|
59424
|
-
*/
|
|
59425
|
-
function firstChild(query, _1, _2, _3, state) {
|
|
59426
|
-
assertDeep(state, query)
|
|
59427
|
-
return state.elementIndex === 0
|
|
59649
|
+
return childState.results.length > 0
|
|
59428
59650
|
}
|
|
59429
59651
|
|
|
59430
59652
|
/**
|
|
59653
|
+
* Check whether an element matches a `:lang()` pseudo.
|
|
59654
|
+
*
|
|
59431
59655
|
* @param {RulePseudo} query
|
|
59432
59656
|
* @param {Element} _1
|
|
59433
|
-
* @param {number|
|
|
59434
|
-
* @param {Parent|
|
|
59657
|
+
* @param {number | undefined} _2
|
|
59658
|
+
* @param {Parent | undefined} _3
|
|
59435
59659
|
* @param {SelectState} state
|
|
59436
59660
|
* @returns {boolean}
|
|
59437
59661
|
*/
|
|
@@ -59439,17 +59663,18 @@ function pseudo_lang(query, _1, _2, _3, state) {
|
|
|
59439
59663
|
return (
|
|
59440
59664
|
state.language !== '' &&
|
|
59441
59665
|
state.language !== undefined &&
|
|
59442
|
-
state.language !== null &&
|
|
59443
59666
|
// @ts-expect-error never `selectors`.
|
|
59444
59667
|
extendedFilter(state.language, comma_separated_tokens_parse(query.value)).length > 0
|
|
59445
59668
|
)
|
|
59446
59669
|
}
|
|
59447
59670
|
|
|
59448
59671
|
/**
|
|
59672
|
+
* Check whether an element matches a `:last-child` pseudo.
|
|
59673
|
+
*
|
|
59449
59674
|
* @param {RulePseudo} query
|
|
59450
59675
|
* @param {Element} _1
|
|
59451
|
-
* @param {number|
|
|
59452
|
-
* @param {Parent|
|
|
59676
|
+
* @param {number | undefined} _2
|
|
59677
|
+
* @param {Parent | undefined} _3
|
|
59453
59678
|
* @param {SelectState} state
|
|
59454
59679
|
* @returns {boolean}
|
|
59455
59680
|
*/
|
|
@@ -59461,115 +59686,160 @@ function lastChild(query, _1, _2, _3, state) {
|
|
|
59461
59686
|
}
|
|
59462
59687
|
|
|
59463
59688
|
/**
|
|
59689
|
+
* Check whether an element matches a `:last-of-type` pseudo.
|
|
59690
|
+
*
|
|
59464
59691
|
* @param {RulePseudo} query
|
|
59465
59692
|
* @param {Element} _1
|
|
59466
|
-
* @param {number|
|
|
59467
|
-
* @param {Parent|
|
|
59693
|
+
* @param {number | undefined} _2
|
|
59694
|
+
* @param {Parent | undefined} _3
|
|
59468
59695
|
* @param {SelectState} state
|
|
59469
59696
|
* @returns {boolean}
|
|
59470
59697
|
*/
|
|
59471
|
-
function
|
|
59698
|
+
function lastOfType(query, _1, _2, _3, state) {
|
|
59472
59699
|
assertDeep(state, query)
|
|
59473
|
-
return
|
|
59700
|
+
return (
|
|
59701
|
+
typeof state.typeIndex === 'number' &&
|
|
59702
|
+
typeof state.typeCount === 'number' &&
|
|
59703
|
+
state.typeIndex === state.typeCount - 1
|
|
59704
|
+
)
|
|
59474
59705
|
}
|
|
59475
59706
|
|
|
59476
59707
|
/**
|
|
59477
|
-
*
|
|
59478
|
-
*
|
|
59479
|
-
* @param {
|
|
59480
|
-
* @param {
|
|
59708
|
+
* Check whether an element `:matches` further selectors.
|
|
59709
|
+
*
|
|
59710
|
+
* @param {RulePseudoSelector} query
|
|
59711
|
+
* @param {Element} element
|
|
59712
|
+
* @param {number | undefined} _
|
|
59713
|
+
* @param {Parent | undefined} parent
|
|
59481
59714
|
* @param {SelectState} state
|
|
59482
59715
|
* @returns {boolean}
|
|
59483
59716
|
*/
|
|
59484
|
-
function
|
|
59485
|
-
|
|
59486
|
-
|
|
59487
|
-
|
|
59488
|
-
|
|
59717
|
+
function matches(query, element, _, parent, state) {
|
|
59718
|
+
/** @type {SelectState} */
|
|
59719
|
+
const childState = {
|
|
59720
|
+
...state,
|
|
59721
|
+
// Do walk deep.
|
|
59722
|
+
shallow: false,
|
|
59723
|
+
// One result is enough.
|
|
59724
|
+
one: true,
|
|
59725
|
+
scopeElements: [element],
|
|
59726
|
+
results: [],
|
|
59727
|
+
rootQuery: queryToSelectors(query.value)
|
|
59728
|
+
}
|
|
59729
|
+
|
|
59730
|
+
walk_walk(childState, element)
|
|
59731
|
+
|
|
59732
|
+
return childState.results[0] === element
|
|
59733
|
+
}
|
|
59734
|
+
|
|
59735
|
+
/**
|
|
59736
|
+
* Check whether an element does `:not` match further selectors.
|
|
59737
|
+
*
|
|
59738
|
+
* @param {RulePseudoSelector} query
|
|
59739
|
+
* @param {Element} element
|
|
59740
|
+
* @param {number | undefined} index
|
|
59741
|
+
* @param {Parent | undefined} parent
|
|
59742
|
+
* @param {SelectState} state
|
|
59743
|
+
* @returns {boolean}
|
|
59744
|
+
*/
|
|
59745
|
+
function not(query, element, index, parent, state) {
|
|
59746
|
+
return !matches(query, element, index, parent, state)
|
|
59489
59747
|
}
|
|
59490
59748
|
|
|
59491
59749
|
/**
|
|
59492
|
-
*
|
|
59750
|
+
* Check whether an element matches an `:nth-child` pseudo.
|
|
59751
|
+
*
|
|
59752
|
+
* @param {RulePseudo} query
|
|
59493
59753
|
* @param {Element} _1
|
|
59494
|
-
* @param {number|
|
|
59495
|
-
* @param {Parent|
|
|
59754
|
+
* @param {number | undefined} _2
|
|
59755
|
+
* @param {Parent | undefined} _3
|
|
59496
59756
|
* @param {SelectState} state
|
|
59497
59757
|
* @returns {boolean}
|
|
59498
59758
|
*/
|
|
59499
|
-
function
|
|
59759
|
+
function nthChild(query, _1, _2, _3, state) {
|
|
59760
|
+
const fn = getCachedNthCheck(query)
|
|
59500
59761
|
assertDeep(state, query)
|
|
59501
|
-
return
|
|
59502
|
-
typeof state.elementCount === 'number' &&
|
|
59503
|
-
typeof state.elementIndex === 'number' &&
|
|
59504
|
-
query.value(state.elementCount - state.elementIndex - 1)
|
|
59505
|
-
)
|
|
59762
|
+
return typeof state.elementIndex === 'number' && fn(state.elementIndex)
|
|
59506
59763
|
}
|
|
59507
59764
|
|
|
59508
59765
|
/**
|
|
59509
|
-
*
|
|
59766
|
+
* Check whether an element matches an `:nth-last-child` pseudo.
|
|
59767
|
+
*
|
|
59768
|
+
* @param {RulePseudo} query
|
|
59510
59769
|
* @param {Element} _1
|
|
59511
|
-
* @param {number|
|
|
59512
|
-
* @param {Parent|
|
|
59770
|
+
* @param {number | undefined} _2
|
|
59771
|
+
* @param {Parent | undefined} _3
|
|
59513
59772
|
* @param {SelectState} state
|
|
59514
59773
|
* @returns {boolean}
|
|
59515
59774
|
*/
|
|
59516
|
-
function
|
|
59775
|
+
function nthLastChild(query, _1, _2, _3, state) {
|
|
59776
|
+
const fn = getCachedNthCheck(query)
|
|
59517
59777
|
assertDeep(state, query)
|
|
59518
|
-
return
|
|
59778
|
+
return Boolean(
|
|
59779
|
+
typeof state.elementCount === 'number' &&
|
|
59780
|
+
typeof state.elementIndex === 'number' &&
|
|
59781
|
+
fn(state.elementCount - state.elementIndex - 1)
|
|
59782
|
+
)
|
|
59519
59783
|
}
|
|
59520
59784
|
|
|
59521
59785
|
/**
|
|
59522
|
-
*
|
|
59786
|
+
* Check whether an element matches a `:nth-last-of-type` pseudo.
|
|
59787
|
+
*
|
|
59788
|
+
* @param {RulePseudo} query
|
|
59523
59789
|
* @param {Element} _1
|
|
59524
|
-
* @param {number|
|
|
59525
|
-
* @param {Parent|
|
|
59790
|
+
* @param {number | undefined} _2
|
|
59791
|
+
* @param {Parent | undefined} _3
|
|
59526
59792
|
* @param {SelectState} state
|
|
59527
59793
|
* @returns {boolean}
|
|
59528
59794
|
*/
|
|
59529
59795
|
function nthLastOfType(query, _1, _2, _3, state) {
|
|
59796
|
+
const fn = getCachedNthCheck(query)
|
|
59530
59797
|
assertDeep(state, query)
|
|
59531
59798
|
return (
|
|
59532
59799
|
typeof state.typeCount === 'number' &&
|
|
59533
59800
|
typeof state.typeIndex === 'number' &&
|
|
59534
|
-
|
|
59801
|
+
fn(state.typeCount - 1 - state.typeIndex)
|
|
59535
59802
|
)
|
|
59536
59803
|
}
|
|
59537
59804
|
|
|
59538
59805
|
/**
|
|
59806
|
+
* Check whether an element matches an `:nth-of-type` pseudo.
|
|
59807
|
+
*
|
|
59539
59808
|
* @param {RulePseudo} query
|
|
59540
59809
|
* @param {Element} _1
|
|
59541
|
-
* @param {number|
|
|
59542
|
-
* @param {Parent|
|
|
59810
|
+
* @param {number | undefined} _2
|
|
59811
|
+
* @param {Parent | undefined} _3
|
|
59543
59812
|
* @param {SelectState} state
|
|
59544
59813
|
* @returns {boolean}
|
|
59545
59814
|
*/
|
|
59546
|
-
function
|
|
59815
|
+
function nthOfType(query, _1, _2, _3, state) {
|
|
59816
|
+
const fn = getCachedNthCheck(query)
|
|
59547
59817
|
assertDeep(state, query)
|
|
59548
|
-
return state.typeIndex ===
|
|
59818
|
+
return typeof state.typeIndex === 'number' && fn(state.typeIndex)
|
|
59549
59819
|
}
|
|
59550
59820
|
|
|
59551
59821
|
/**
|
|
59822
|
+
* Check whether an element matches an `:only-child` pseudo.
|
|
59823
|
+
*
|
|
59552
59824
|
* @param {RulePseudo} query
|
|
59553
59825
|
* @param {Element} _1
|
|
59554
|
-
* @param {number|
|
|
59555
|
-
* @param {Parent|
|
|
59826
|
+
* @param {number | undefined} _2
|
|
59827
|
+
* @param {Parent | undefined} _3
|
|
59556
59828
|
* @param {SelectState} state
|
|
59557
59829
|
* @returns {boolean}
|
|
59558
59830
|
*/
|
|
59559
|
-
function
|
|
59831
|
+
function onlyChild(query, _1, _2, _3, state) {
|
|
59560
59832
|
assertDeep(state, query)
|
|
59561
|
-
return
|
|
59562
|
-
typeof state.typeIndex === 'number' &&
|
|
59563
|
-
typeof state.typeCount === 'number' &&
|
|
59564
|
-
state.typeIndex === state.typeCount - 1
|
|
59565
|
-
)
|
|
59833
|
+
return state.elementCount === 1
|
|
59566
59834
|
}
|
|
59567
59835
|
|
|
59568
59836
|
/**
|
|
59837
|
+
* Check whether an element matches an `:only-of-type` pseudo.
|
|
59838
|
+
*
|
|
59569
59839
|
* @param {RulePseudo} query
|
|
59570
59840
|
* @param {Element} _1
|
|
59571
|
-
* @param {number|
|
|
59572
|
-
* @param {Parent|
|
|
59841
|
+
* @param {number | undefined} _2
|
|
59842
|
+
* @param {Parent | undefined} _3
|
|
59573
59843
|
* @param {SelectState} state
|
|
59574
59844
|
* @returns {boolean}
|
|
59575
59845
|
*/
|
|
@@ -59579,389 +59849,168 @@ function onlyOfType(query, _1, _2, _3, state) {
|
|
|
59579
59849
|
}
|
|
59580
59850
|
|
|
59581
59851
|
/**
|
|
59582
|
-
*
|
|
59583
|
-
*
|
|
59584
|
-
* @returns {boolean}
|
|
59585
|
-
*/
|
|
59586
|
-
function someChildren(element, check) {
|
|
59587
|
-
const children = element.children
|
|
59588
|
-
let index = -1
|
|
59589
|
-
|
|
59590
|
-
while (++index < children.length) {
|
|
59591
|
-
if (check(children[index])) return true
|
|
59592
|
-
}
|
|
59593
|
-
|
|
59594
|
-
return false
|
|
59595
|
-
}
|
|
59596
|
-
|
|
59597
|
-
// Shouldn’t be called, parser gives correct data.
|
|
59598
|
-
/* c8 ignore next 3 */
|
|
59599
|
-
function invalidPseudo() {
|
|
59600
|
-
throw new Error('Invalid pseudo-selector')
|
|
59601
|
-
}
|
|
59602
|
-
|
|
59603
|
-
/**
|
|
59852
|
+
* Check whether an element matches an `:optional` pseudo.
|
|
59853
|
+
*
|
|
59604
59854
|
* @param {RulePseudo} query
|
|
59605
|
-
*/
|
|
59606
|
-
function unknownPseudo(query) {
|
|
59607
|
-
if (query.name) {
|
|
59608
|
-
throw new Error('Unknown pseudo-selector `' + query.name + '`')
|
|
59609
|
-
}
|
|
59610
|
-
|
|
59611
|
-
throw new Error('Unexpected pseudo-element or empty pseudo-class')
|
|
59612
|
-
}
|
|
59613
|
-
|
|
59614
|
-
/**
|
|
59615
|
-
* @param {SelectState} state
|
|
59616
|
-
* @param {RulePseudo|RulePseudoNth} query
|
|
59617
|
-
*/
|
|
59618
|
-
function assertDeep(state, query) {
|
|
59619
|
-
if (state.shallow) {
|
|
59620
|
-
throw new Error('Cannot use `:' + query.name + '` without parent')
|
|
59621
|
-
}
|
|
59622
|
-
}
|
|
59623
|
-
|
|
59624
|
-
/**
|
|
59625
|
-
* @param {RulePseudoSelector} query
|
|
59626
59855
|
* @param {Element} element
|
|
59627
|
-
* @param {number|null} _2
|
|
59628
|
-
* @param {Parent|null} _3
|
|
59629
|
-
* @param {SelectState} state
|
|
59630
59856
|
* @returns {boolean}
|
|
59631
59857
|
*/
|
|
59632
|
-
function
|
|
59633
|
-
|
|
59634
|
-
const one = state.one
|
|
59635
|
-
const scopeElements = state.scopeElements
|
|
59636
|
-
const value = appendScope(query.value)
|
|
59637
|
-
|
|
59638
|
-
state.shallow = false
|
|
59639
|
-
state.one = true
|
|
59640
|
-
state.scopeElements = [element]
|
|
59641
|
-
|
|
59642
|
-
const result = any_any(value, element, state).length > 0
|
|
59643
|
-
|
|
59644
|
-
state.shallow = shallow
|
|
59645
|
-
state.one = one
|
|
59646
|
-
state.scopeElements = scopeElements
|
|
59647
|
-
|
|
59648
|
-
return result
|
|
59649
|
-
}
|
|
59650
|
-
|
|
59651
|
-
/**
|
|
59652
|
-
* @param {Selector} value
|
|
59653
|
-
* @returns {Selectors}
|
|
59654
|
-
*/
|
|
59655
|
-
function appendScope(value) {
|
|
59656
|
-
/** @type {Selectors} */
|
|
59657
|
-
const selector =
|
|
59658
|
-
value.type === 'ruleSet' ? {type: 'selectors', selectors: [value]} : value
|
|
59659
|
-
let index = -1
|
|
59660
|
-
|
|
59661
|
-
while (++index < selector.selectors.length) {
|
|
59662
|
-
const rule = selector.selectors[index].rule
|
|
59663
|
-
rule.nestingOperator = null
|
|
59664
|
-
|
|
59665
|
-
if (
|
|
59666
|
-
!rule.pseudos ||
|
|
59667
|
-
rule.pseudos.length !== 1 ||
|
|
59668
|
-
rule.pseudos[0].name !== 'scope'
|
|
59669
|
-
) {
|
|
59670
|
-
selector.selectors[index] = {
|
|
59671
|
-
type: 'ruleSet',
|
|
59672
|
-
// @ts-expect-error pseudos are fine w/ just a name!
|
|
59673
|
-
rule: {type: 'rule', rule, pseudos: [{name: 'scope'}]}
|
|
59674
|
-
}
|
|
59675
|
-
}
|
|
59676
|
-
}
|
|
59677
|
-
|
|
59678
|
-
return selector
|
|
59679
|
-
}
|
|
59680
|
-
|
|
59681
|
-
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/attribute.js
|
|
59682
|
-
/**
|
|
59683
|
-
* @typedef {import('./types.js').Rule} Rule
|
|
59684
|
-
* @typedef {import('./types.js').RuleAttr} RuleAttr
|
|
59685
|
-
* @typedef {import('./types.js').Element} Element
|
|
59686
|
-
* @typedef {import('./types.js').Schema} Schema
|
|
59687
|
-
* @typedef {import('./types.js').Info} Info
|
|
59688
|
-
* @typedef {import('./types.js').PropertyValue} PropertyValue
|
|
59689
|
-
*/
|
|
59690
|
-
|
|
59691
|
-
|
|
59692
|
-
|
|
59693
|
-
|
|
59694
|
-
|
|
59695
|
-
|
|
59696
|
-
|
|
59697
|
-
const attribute_handle = zwitch('operator', {
|
|
59698
|
-
// @ts-expect-error: hush.
|
|
59699
|
-
unknown: unknownOperator,
|
|
59700
|
-
// @ts-expect-error: hush.
|
|
59701
|
-
invalid: exists,
|
|
59702
|
-
handlers: {
|
|
59703
|
-
// @ts-expect-error: hush.
|
|
59704
|
-
'=': exact,
|
|
59705
|
-
// @ts-expect-error: hush.
|
|
59706
|
-
'~=': spaceSeparatedList,
|
|
59707
|
-
// @ts-expect-error: hush.
|
|
59708
|
-
'|=': exactOrPrefix,
|
|
59709
|
-
// @ts-expect-error: hush.
|
|
59710
|
-
'^=': begins,
|
|
59711
|
-
// @ts-expect-error: hush.
|
|
59712
|
-
'$=': ends,
|
|
59713
|
-
// @ts-expect-error: hush.
|
|
59714
|
-
'*=': contains
|
|
59715
|
-
}
|
|
59716
|
-
})
|
|
59717
|
-
|
|
59718
|
-
/**
|
|
59719
|
-
* @param {Rule} query
|
|
59720
|
-
* @param {Element} element
|
|
59721
|
-
* @param {Schema} schema
|
|
59722
|
-
* @returns {boolean}
|
|
59723
|
-
*/
|
|
59724
|
-
function attribute(query, element, schema) {
|
|
59725
|
-
const attrs = query.attrs
|
|
59726
|
-
let index = -1
|
|
59727
|
-
|
|
59728
|
-
while (++index < attrs.length) {
|
|
59729
|
-
if (!attribute_handle(attrs[index], element, find(schema, attrs[index].name))) {
|
|
59730
|
-
return false
|
|
59731
|
-
}
|
|
59732
|
-
}
|
|
59733
|
-
|
|
59734
|
-
return true
|
|
59858
|
+
function optional(query, element) {
|
|
59859
|
+
return !required(query, element)
|
|
59735
59860
|
}
|
|
59736
59861
|
|
|
59737
59862
|
/**
|
|
59738
|
-
* `
|
|
59863
|
+
* Check whether an element matches a `:read-only` pseudo.
|
|
59739
59864
|
*
|
|
59740
|
-
* @param {
|
|
59865
|
+
* @param {RulePseudo} query
|
|
59741
59866
|
* @param {Element} element
|
|
59742
|
-
* @param {
|
|
59867
|
+
* @param {number | undefined} index
|
|
59868
|
+
* @param {Parent | undefined} parent
|
|
59869
|
+
* @param {SelectState} state
|
|
59743
59870
|
* @returns {boolean}
|
|
59744
59871
|
*/
|
|
59745
|
-
function
|
|
59746
|
-
return
|
|
59872
|
+
function readOnly(query, element, index, parent, state) {
|
|
59873
|
+
return !readWrite(query, element, index, parent, state)
|
|
59747
59874
|
}
|
|
59748
59875
|
|
|
59749
59876
|
/**
|
|
59750
|
-
* `
|
|
59877
|
+
* Check whether an element matches a `:read-write` pseudo.
|
|
59751
59878
|
*
|
|
59752
|
-
* @param {
|
|
59879
|
+
* @param {RulePseudo} _
|
|
59753
59880
|
* @param {Element} element
|
|
59754
|
-
* @param {
|
|
59881
|
+
* @param {number | undefined} _1
|
|
59882
|
+
* @param {Parent | undefined} _2
|
|
59883
|
+
* @param {SelectState} state
|
|
59755
59884
|
* @returns {boolean}
|
|
59756
59885
|
*/
|
|
59757
|
-
function
|
|
59758
|
-
return
|
|
59759
|
-
hasProperty(element,
|
|
59760
|
-
|
|
59761
|
-
normalizeValue(element.properties[info.property], info) === query.value
|
|
59762
|
-
)
|
|
59886
|
+
function readWrite(_, element, _1, _2, state) {
|
|
59887
|
+
return element.tagName === 'input' || element.tagName === 'textarea'
|
|
59888
|
+
? !hasProperty(element, 'readOnly') && !hasProperty(element, 'disabled')
|
|
59889
|
+
: Boolean(state.editableOrEditingHost)
|
|
59763
59890
|
}
|
|
59764
59891
|
|
|
59765
59892
|
/**
|
|
59766
|
-
* `
|
|
59893
|
+
* Check whether an element matches a `:required` pseudo.
|
|
59767
59894
|
*
|
|
59768
|
-
* @param {
|
|
59895
|
+
* @param {RulePseudo} _
|
|
59769
59896
|
* @param {Element} element
|
|
59770
|
-
* @param {Info} info
|
|
59771
59897
|
* @returns {boolean}
|
|
59772
59898
|
*/
|
|
59773
|
-
function
|
|
59774
|
-
const value = element.properties && element.properties[info.property]
|
|
59775
|
-
|
|
59899
|
+
function required(_, element) {
|
|
59776
59900
|
return (
|
|
59777
|
-
|
|
59778
|
-
|
|
59779
|
-
|
|
59780
|
-
|
|
59781
|
-
typeof value === 'object' &&
|
|
59782
|
-
query.value &&
|
|
59783
|
-
value.includes(query.value)) ||
|
|
59784
|
-
// For all other values (including comma-separated lists), return whether this
|
|
59785
|
-
// is an exact match.
|
|
59786
|
-
(hasProperty(element, info.property) &&
|
|
59787
|
-
normalizeValue(value, info) === query.value)
|
|
59788
|
-
)
|
|
59789
|
-
}
|
|
59790
|
-
|
|
59791
|
-
/**
|
|
59792
|
-
* `[attr|=value]`
|
|
59793
|
-
*
|
|
59794
|
-
* @param {RuleAttr} query
|
|
59795
|
-
* @param {Element} element
|
|
59796
|
-
* @param {Info} info
|
|
59797
|
-
* @returns {boolean}
|
|
59798
|
-
*/
|
|
59799
|
-
function exactOrPrefix(query, element, info) {
|
|
59800
|
-
const value = normalizeValue(
|
|
59801
|
-
element.properties && element.properties[info.property],
|
|
59802
|
-
info
|
|
59803
|
-
)
|
|
59804
|
-
|
|
59805
|
-
return Boolean(
|
|
59806
|
-
hasProperty(element, info.property) &&
|
|
59807
|
-
query.value &&
|
|
59808
|
-
(value === query.value ||
|
|
59809
|
-
(value.slice(0, query.value.length) === query.value &&
|
|
59810
|
-
value.charAt(query.value.length) === '-'))
|
|
59811
|
-
)
|
|
59812
|
-
}
|
|
59813
|
-
|
|
59814
|
-
/**
|
|
59815
|
-
* `[attr^=value]`
|
|
59816
|
-
*
|
|
59817
|
-
* @param {RuleAttr} query
|
|
59818
|
-
* @param {Element} element
|
|
59819
|
-
* @param {Info} info
|
|
59820
|
-
* @returns {boolean}
|
|
59821
|
-
*/
|
|
59822
|
-
function begins(query, element, info) {
|
|
59823
|
-
return Boolean(
|
|
59824
|
-
hasProperty(element, info.property) &&
|
|
59825
|
-
element.properties &&
|
|
59826
|
-
query.value &&
|
|
59827
|
-
normalizeValue(element.properties[info.property], info).slice(
|
|
59828
|
-
0,
|
|
59829
|
-
query.value.length
|
|
59830
|
-
) === query.value
|
|
59901
|
+
(element.tagName === 'input' ||
|
|
59902
|
+
element.tagName === 'textarea' ||
|
|
59903
|
+
element.tagName === 'select') &&
|
|
59904
|
+
hasProperty(element, 'required')
|
|
59831
59905
|
)
|
|
59832
59906
|
}
|
|
59833
59907
|
|
|
59834
59908
|
/**
|
|
59835
|
-
* `
|
|
59909
|
+
* Check whether an element matches a `:root` pseudo.
|
|
59836
59910
|
*
|
|
59837
|
-
* @param {
|
|
59911
|
+
* @param {RulePseudo} _
|
|
59838
59912
|
* @param {Element} element
|
|
59839
|
-
* @param {
|
|
59913
|
+
* @param {number | undefined} _1
|
|
59914
|
+
* @param {Parent | undefined} parent
|
|
59915
|
+
* @param {SelectState} state
|
|
59840
59916
|
* @returns {boolean}
|
|
59841
59917
|
*/
|
|
59842
|
-
function
|
|
59918
|
+
function pseudo_root(_, element, _1, parent, state) {
|
|
59843
59919
|
return Boolean(
|
|
59844
|
-
|
|
59845
|
-
|
|
59846
|
-
|
|
59847
|
-
|
|
59848
|
-
-query.value.length
|
|
59849
|
-
) === query.value
|
|
59920
|
+
(!parent || parent.type === 'root') &&
|
|
59921
|
+
state.schema &&
|
|
59922
|
+
(state.schema.space === 'html' || state.schema.space === 'svg') &&
|
|
59923
|
+
(element.tagName === 'html' || element.tagName === 'svg')
|
|
59850
59924
|
)
|
|
59851
59925
|
}
|
|
59852
59926
|
|
|
59853
59927
|
/**
|
|
59854
|
-
* `
|
|
59928
|
+
* Check whether an element matches a `:scope` pseudo.
|
|
59855
59929
|
*
|
|
59856
|
-
* @param {
|
|
59930
|
+
* @param {RulePseudo} _
|
|
59857
59931
|
* @param {Element} element
|
|
59858
|
-
* @param {
|
|
59932
|
+
* @param {number | undefined} _1
|
|
59933
|
+
* @param {Parent | undefined} _2
|
|
59934
|
+
* @param {SelectState} state
|
|
59859
59935
|
* @returns {boolean}
|
|
59860
59936
|
*/
|
|
59861
|
-
function
|
|
59862
|
-
return
|
|
59863
|
-
hasProperty(element, info.property) &&
|
|
59864
|
-
element.properties &&
|
|
59865
|
-
query.value &&
|
|
59866
|
-
normalizeValue(element.properties[info.property], info).includes(
|
|
59867
|
-
query.value
|
|
59868
|
-
)
|
|
59869
|
-
)
|
|
59937
|
+
function scope(_, element, _1, _2, state) {
|
|
59938
|
+
return state.scopeElements.includes(element)
|
|
59870
59939
|
}
|
|
59871
59940
|
|
|
59872
|
-
// Shouldn’t be called,
|
|
59873
|
-
/**
|
|
59874
|
-
* @param {RuleAttr} query
|
|
59875
|
-
* @returns {boolean}
|
|
59876
|
-
*/
|
|
59941
|
+
// Shouldn’t be called, parser gives correct data.
|
|
59877
59942
|
/* c8 ignore next 3 */
|
|
59878
|
-
function
|
|
59879
|
-
throw new Error('
|
|
59943
|
+
function invalidPseudo() {
|
|
59944
|
+
throw new Error('Invalid pseudo-selector')
|
|
59880
59945
|
}
|
|
59881
59946
|
|
|
59882
59947
|
/**
|
|
59883
|
-
*
|
|
59884
|
-
*
|
|
59885
|
-
* @param {PropertyValue} value
|
|
59886
|
-
* @param {Info} info
|
|
59887
|
-
* @returns {string}
|
|
59948
|
+
* @param {unknown} query
|
|
59949
|
+
* @returns {never}
|
|
59888
59950
|
*/
|
|
59889
|
-
function
|
|
59890
|
-
|
|
59891
|
-
|
|
59892
|
-
|
|
59893
|
-
|
|
59894
|
-
if (Array.isArray(value)) {
|
|
59895
|
-
return (info.commaSeparated ? comma_separated_tokens_stringify : stringify)(value)
|
|
59951
|
+
function unknownPseudo(query) {
|
|
59952
|
+
// @ts-expect-error: indexable.
|
|
59953
|
+
if (query.name) {
|
|
59954
|
+
// @ts-expect-error: indexable.
|
|
59955
|
+
throw new Error('Unknown pseudo-selector `' + query.name + '`')
|
|
59896
59956
|
}
|
|
59897
59957
|
|
|
59898
|
-
|
|
59958
|
+
throw new Error('Unexpected pseudo-element or empty pseudo-class')
|
|
59899
59959
|
}
|
|
59900
59960
|
|
|
59901
|
-
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/class-name.js
|
|
59902
59961
|
/**
|
|
59903
|
-
*
|
|
59904
|
-
*
|
|
59905
|
-
*/
|
|
59906
|
-
|
|
59907
|
-
/**
|
|
59908
|
-
* @param {Rule} query
|
|
59962
|
+
* Check children.
|
|
59963
|
+
*
|
|
59909
59964
|
* @param {Element} element
|
|
59965
|
+
* @param {(child: ElementChild) => boolean} check
|
|
59910
59966
|
* @returns {boolean}
|
|
59911
59967
|
*/
|
|
59912
|
-
function
|
|
59913
|
-
|
|
59914
|
-
// @ts-expect-error Assume array.
|
|
59915
|
-
const value = element.properties.className || []
|
|
59968
|
+
function someChildren(element, check) {
|
|
59969
|
+
const children = element.children
|
|
59916
59970
|
let index = -1
|
|
59917
59971
|
|
|
59918
|
-
|
|
59919
|
-
|
|
59920
|
-
if (!value.includes(query.classNames[index])) return false
|
|
59921
|
-
}
|
|
59972
|
+
while (++index < children.length) {
|
|
59973
|
+
if (check(children[index])) return true
|
|
59922
59974
|
}
|
|
59923
59975
|
|
|
59924
|
-
return
|
|
59976
|
+
return false
|
|
59925
59977
|
}
|
|
59926
59978
|
|
|
59927
|
-
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/id.js
|
|
59928
59979
|
/**
|
|
59929
|
-
* @
|
|
59930
|
-
* @
|
|
59931
|
-
*/
|
|
59932
|
-
|
|
59933
|
-
/**
|
|
59934
|
-
* @param {Rule} query
|
|
59935
|
-
* @param {Element} element
|
|
59936
|
-
* @returns {boolean}
|
|
59980
|
+
* @param {SelectState} state
|
|
59981
|
+
* @param {RulePseudo} query
|
|
59937
59982
|
*/
|
|
59938
|
-
function
|
|
59939
|
-
|
|
59983
|
+
function assertDeep(state, query) {
|
|
59984
|
+
if (state.shallow) {
|
|
59985
|
+
throw new Error('Cannot use `:' + query.name + '` without parent')
|
|
59986
|
+
}
|
|
59940
59987
|
}
|
|
59941
59988
|
|
|
59942
|
-
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/name.js
|
|
59943
59989
|
/**
|
|
59944
|
-
* @
|
|
59945
|
-
* @
|
|
59990
|
+
* @param {RulePseudo} query
|
|
59991
|
+
* @returns {(value: number) => boolean}
|
|
59946
59992
|
*/
|
|
59993
|
+
function getCachedNthCheck(query) {
|
|
59994
|
+
/** @type {(value: number) => boolean} */
|
|
59995
|
+
// @ts-expect-error: cache.
|
|
59996
|
+
let fn = query._cachedFn
|
|
59947
59997
|
|
|
59948
|
-
|
|
59949
|
-
|
|
59950
|
-
|
|
59951
|
-
|
|
59952
|
-
|
|
59953
|
-
|
|
59954
|
-
|
|
59998
|
+
if (!fn) {
|
|
59999
|
+
// @ts-expect-error: always string.
|
|
60000
|
+
fn = pseudo_nthCheck(query.value)
|
|
60001
|
+
// @ts-expect-error: cache.
|
|
60002
|
+
query._cachedFn = fn
|
|
60003
|
+
}
|
|
60004
|
+
|
|
60005
|
+
return fn
|
|
59955
60006
|
}
|
|
59956
60007
|
|
|
59957
60008
|
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/test.js
|
|
59958
60009
|
/**
|
|
59959
60010
|
* @typedef {import('./types.js').Rule} Rule
|
|
59960
|
-
* @typedef {import('./types.js').HastNode} HastNode
|
|
59961
60011
|
* @typedef {import('./types.js').Element} Element
|
|
59962
60012
|
* @typedef {import('./types.js').Parent} Parent
|
|
59963
60013
|
* @typedef {import('./types.js').SelectState} SelectState
|
|
59964
|
-
* @typedef {import('hast-util-is-element').AssertPredicate<Element>} IsElement
|
|
59965
60014
|
*/
|
|
59966
60015
|
|
|
59967
60016
|
|
|
@@ -59970,609 +60019,468 @@ function name_name(query, element) {
|
|
|
59970
60019
|
|
|
59971
60020
|
|
|
59972
60021
|
|
|
59973
|
-
|
|
59974
60022
|
/**
|
|
60023
|
+
* Test a rule.
|
|
60024
|
+
*
|
|
59975
60025
|
* @param {Rule} query
|
|
59976
|
-
* @param {
|
|
59977
|
-
* @param {number|
|
|
59978
|
-
* @param {Parent|
|
|
60026
|
+
* @param {Element} element
|
|
60027
|
+
* @param {number | undefined} index
|
|
60028
|
+
* @param {Parent | undefined} parent
|
|
59979
60029
|
* @param {SelectState} state
|
|
59980
60030
|
* @returns {boolean}
|
|
59981
60031
|
*/
|
|
59982
|
-
function test(query,
|
|
60032
|
+
function test(query, element, index, parent, state) {
|
|
59983
60033
|
return Boolean(
|
|
59984
|
-
|
|
59985
|
-
|
|
59986
|
-
(!query.
|
|
59987
|
-
(!query.
|
|
59988
|
-
(!query.
|
|
59989
|
-
(!query.attrs || attribute(query, node, state.schema)) &&
|
|
59990
|
-
(!query.pseudos || pseudo(query, node, index, parent, state))
|
|
60034
|
+
(!query.tagName || name_name(query, element)) &&
|
|
60035
|
+
(!query.classNames || className(query, element)) &&
|
|
60036
|
+
(!query.id || id(query, element)) &&
|
|
60037
|
+
(!query.attrs || attribute(query, element, state.schema)) &&
|
|
60038
|
+
(!query.pseudos || pseudo(query, element, index, parent, state))
|
|
59991
60039
|
)
|
|
59992
60040
|
}
|
|
59993
60041
|
|
|
59994
|
-
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/
|
|
60042
|
+
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/walk.js
|
|
59995
60043
|
/**
|
|
59996
|
-
* @typedef {import('
|
|
59997
|
-
* @typedef {import('./types.js').
|
|
59998
|
-
* @typedef {import('./types.js').
|
|
60044
|
+
* @typedef {import('./types.js').Node} Node
|
|
60045
|
+
* @typedef {import('./types.js').Element} Element
|
|
60046
|
+
* @typedef {import('./types.js').Parent} Parent
|
|
59999
60047
|
* @typedef {import('./types.js').RuleSet} RuleSet
|
|
60000
|
-
* @typedef {import('./types.js').HastNode} HastNode
|
|
60001
|
-
* @typedef {import('./types.js').SelectIterator} SelectIterator
|
|
60002
60048
|
* @typedef {import('./types.js').SelectState} SelectState
|
|
60049
|
+
* @typedef {import('./types.js').Selectors} Selectors
|
|
60050
|
+
*
|
|
60051
|
+
* @typedef Nest
|
|
60052
|
+
* Rule sets by nesting.
|
|
60053
|
+
* @property {Array<RuleSet> | undefined} descendant
|
|
60054
|
+
* `a b`
|
|
60055
|
+
* @property {Array<RuleSet> | undefined} directChild
|
|
60056
|
+
* `a > b`
|
|
60057
|
+
* @property {Array<RuleSet> | undefined} adjacentSibling
|
|
60058
|
+
* `a + b`
|
|
60059
|
+
* @property {Array<RuleSet> | undefined} generalSibling
|
|
60060
|
+
* `a ~ b`
|
|
60061
|
+
*
|
|
60062
|
+
* @typedef Counts
|
|
60063
|
+
* Info on elements in a parent.
|
|
60064
|
+
* @property {number} count
|
|
60065
|
+
* Number of elements.
|
|
60066
|
+
* @property {Map<string, number>} types
|
|
60067
|
+
* Number of elements by tag name.
|
|
60003
60068
|
*/
|
|
60004
60069
|
|
|
60005
60070
|
|
|
60006
60071
|
|
|
60007
60072
|
|
|
60008
|
-
|
|
60009
|
-
|
|
60010
|
-
|
|
60011
|
-
|
|
60012
|
-
const type = zwitch('type', {
|
|
60013
|
-
// @ts-expect-error: hush.
|
|
60014
|
-
unknown: unknownType,
|
|
60015
|
-
invalid: invalidType,
|
|
60016
|
-
// @ts-expect-error: hush.
|
|
60017
|
-
handlers: {selectors, ruleSet, rule}
|
|
60018
|
-
})
|
|
60073
|
+
/** @type {Array<never>} */
|
|
60074
|
+
const walk_empty = []
|
|
60019
60075
|
|
|
60020
60076
|
/**
|
|
60021
|
-
*
|
|
60022
|
-
*
|
|
60023
|
-
* @param {
|
|
60024
|
-
* @returns {
|
|
60025
|
-
*/
|
|
60026
|
-
function any_any(query, node, state) {
|
|
60027
|
-
// @ts-expect-error zwitch types are off.
|
|
60028
|
-
return query && node ? type(query, node, state) : []
|
|
60029
|
-
}
|
|
60030
|
-
|
|
60031
|
-
/**
|
|
60032
|
-
* @param {Selectors} query
|
|
60033
|
-
* @param {HastNode} node
|
|
60034
|
-
* @param {SelectState} state
|
|
60035
|
-
* @returns {Array<Element>}
|
|
60077
|
+
* Turn a query into a uniform object.
|
|
60078
|
+
*
|
|
60079
|
+
* @param {Selectors | RuleSet | null} query
|
|
60080
|
+
* @returns {Selectors}
|
|
60036
60081
|
*/
|
|
60037
|
-
function
|
|
60038
|
-
|
|
60039
|
-
|
|
60082
|
+
function queryToSelectors(query) {
|
|
60083
|
+
if (query === null) {
|
|
60084
|
+
return {type: 'selectors', selectors: []}
|
|
60085
|
+
}
|
|
60040
60086
|
|
|
60041
|
-
|
|
60042
|
-
|
|
60087
|
+
if (query.type === 'ruleSet') {
|
|
60088
|
+
return {type: 'selectors', selectors: [query]}
|
|
60043
60089
|
}
|
|
60044
60090
|
|
|
60045
|
-
return
|
|
60091
|
+
return query
|
|
60046
60092
|
}
|
|
60047
60093
|
|
|
60048
60094
|
/**
|
|
60049
|
-
*
|
|
60050
|
-
*
|
|
60095
|
+
* Walk a tree.
|
|
60096
|
+
*
|
|
60051
60097
|
* @param {SelectState} state
|
|
60052
|
-
* @
|
|
60098
|
+
* @param {Node | undefined} tree
|
|
60053
60099
|
*/
|
|
60054
|
-
function
|
|
60055
|
-
|
|
60100
|
+
function walk_walk(state, tree) {
|
|
60101
|
+
if (tree) {
|
|
60102
|
+
walk_one(state, [], tree, undefined, undefined)
|
|
60103
|
+
}
|
|
60056
60104
|
}
|
|
60057
60105
|
|
|
60058
60106
|
/**
|
|
60059
|
-
*
|
|
60060
|
-
*
|
|
60107
|
+
* Check a node.
|
|
60108
|
+
*
|
|
60061
60109
|
* @param {SelectState} state
|
|
60062
|
-
* @
|
|
60110
|
+
* @param {Array<RuleSet>} currentRules
|
|
60111
|
+
* @param {Node} node
|
|
60112
|
+
* @param {number | undefined} index
|
|
60113
|
+
* @param {Parent | undefined} parent
|
|
60114
|
+
* @returns {Nest}
|
|
60063
60115
|
*/
|
|
60064
|
-
function
|
|
60065
|
-
|
|
60066
|
-
|
|
60067
|
-
|
|
60068
|
-
|
|
60116
|
+
function walk_one(state, currentRules, node, index, parent) {
|
|
60117
|
+
/** @type {Nest} */
|
|
60118
|
+
let nestResult = {
|
|
60119
|
+
directChild: undefined,
|
|
60120
|
+
descendant: undefined,
|
|
60121
|
+
adjacentSibling: undefined,
|
|
60122
|
+
generalSibling: undefined
|
|
60069
60123
|
}
|
|
60124
|
+
const exit = enterState(state, node)
|
|
60070
60125
|
|
|
60071
|
-
|
|
60072
|
-
|
|
60073
|
-
|
|
60074
|
-
|
|
60075
|
-
|
|
60076
|
-
|
|
60077
|
-
|
|
60078
|
-
|
|
60079
|
-
|
|
60080
|
-
editableOrEditingHost: false,
|
|
60081
|
-
// @ts-expect-error assume elements.
|
|
60082
|
-
scopeElements: tree.type === 'root' ? tree.children : [tree],
|
|
60083
|
-
iterator,
|
|
60084
|
-
one: state.one,
|
|
60085
|
-
shallow: state.shallow
|
|
60086
|
-
})
|
|
60087
|
-
)
|
|
60088
|
-
|
|
60089
|
-
return collector.result
|
|
60090
|
-
|
|
60091
|
-
/** @type {SelectIterator} */
|
|
60092
|
-
function iterator(query, node, index, parent, state) {
|
|
60093
|
-
const exit = enterState(state, node)
|
|
60094
|
-
|
|
60095
|
-
if (test(query, node, index, parent, state)) {
|
|
60096
|
-
if (query.rule) {
|
|
60097
|
-
nest(query.rule, node, index, parent, configure(query.rule, state))
|
|
60098
|
-
} else {
|
|
60099
|
-
// @ts-expect-error `test` also asserts `node is Element`
|
|
60100
|
-
collector.collect(node)
|
|
60101
|
-
state.found = true
|
|
60102
|
-
}
|
|
60103
|
-
}
|
|
60104
|
-
|
|
60105
|
-
exit()
|
|
60126
|
+
if (node.type === 'element') {
|
|
60127
|
+
nestResult = applySelectors(
|
|
60128
|
+
state,
|
|
60129
|
+
// Try the root rules for this element too.
|
|
60130
|
+
combine(currentRules, state.rootQuery.selectors),
|
|
60131
|
+
node,
|
|
60132
|
+
index,
|
|
60133
|
+
parent
|
|
60134
|
+
)
|
|
60106
60135
|
}
|
|
60107
60136
|
|
|
60108
|
-
|
|
60109
|
-
|
|
60110
|
-
|
|
60111
|
-
|
|
60112
|
-
|
|
60113
|
-
*/
|
|
60114
|
-
function configure(query, state) {
|
|
60115
|
-
const pseudos = query.pseudos || []
|
|
60116
|
-
let index = -1
|
|
60137
|
+
// If this is a parent, and we want to delve into them, and we haven’t found
|
|
60138
|
+
// our single result yet.
|
|
60139
|
+
if ('children' in node && !state.shallow && !(state.one && state.found)) {
|
|
60140
|
+
walk_all(state, nestResult, node)
|
|
60141
|
+
}
|
|
60117
60142
|
|
|
60118
|
-
|
|
60119
|
-
if (pseudo.needsIndex.includes(pseudos[index].name)) {
|
|
60120
|
-
state.index = true
|
|
60121
|
-
break
|
|
60122
|
-
}
|
|
60123
|
-
}
|
|
60143
|
+
exit()
|
|
60124
60144
|
|
|
60125
|
-
|
|
60126
|
-
}
|
|
60145
|
+
return nestResult
|
|
60127
60146
|
}
|
|
60128
60147
|
|
|
60129
|
-
// Shouldn’t be called, all data is handled.
|
|
60130
|
-
/* c8 ignore next 6 */
|
|
60131
60148
|
/**
|
|
60132
|
-
*
|
|
60149
|
+
* Check a node.
|
|
60150
|
+
*
|
|
60151
|
+
* @param {SelectState} state
|
|
60152
|
+
* @param {Nest} nest
|
|
60153
|
+
* @param {Parent} node
|
|
60154
|
+
* @returns {void}
|
|
60133
60155
|
*/
|
|
60134
|
-
function
|
|
60135
|
-
|
|
60136
|
-
}
|
|
60137
|
-
|
|
60138
|
-
|
|
60139
|
-
/* c8 ignore next 3 */
|
|
60140
|
-
function invalidType() {
|
|
60141
|
-
throw new Error('Invalid type')
|
|
60142
|
-
}
|
|
60143
|
-
|
|
60144
|
-
class Collector {
|
|
60156
|
+
function walk_all(state, nest, node) {
|
|
60157
|
+
const fromParent = combine(nest.descendant, nest.directChild)
|
|
60158
|
+
/** @type {Array<RuleSet> | undefined} */
|
|
60159
|
+
let fromSibling
|
|
60160
|
+
let index = -1
|
|
60145
60161
|
/**
|
|
60146
|
-
*
|
|
60162
|
+
* Total counts.
|
|
60163
|
+
* @type {Counts}
|
|
60147
60164
|
*/
|
|
60148
|
-
|
|
60149
|
-
/** @type {Array<Element>} */
|
|
60150
|
-
this.result = []
|
|
60151
|
-
/** @type {boolean|undefined} */
|
|
60152
|
-
this.one = one
|
|
60153
|
-
/** @type {boolean} */
|
|
60154
|
-
this.found = false
|
|
60155
|
-
}
|
|
60156
|
-
|
|
60165
|
+
const total = {count: 0, types: new Map()}
|
|
60157
60166
|
/**
|
|
60158
|
-
*
|
|
60159
|
-
*
|
|
60160
|
-
* @param {Array<Element>} elements
|
|
60167
|
+
* Counts of previous siblings.
|
|
60168
|
+
* @type {Counts}
|
|
60161
60169
|
*/
|
|
60162
|
-
|
|
60163
|
-
let index = -1
|
|
60170
|
+
const before = {count: 0, types: new Map()}
|
|
60164
60171
|
|
|
60165
|
-
|
|
60166
|
-
|
|
60167
|
-
}
|
|
60172
|
+
while (++index < node.children.length) {
|
|
60173
|
+
count(total, node.children[index])
|
|
60168
60174
|
}
|
|
60169
60175
|
|
|
60170
|
-
|
|
60171
|
-
|
|
60172
|
-
|
|
60173
|
-
|
|
60174
|
-
|
|
60175
|
-
|
|
60176
|
-
|
|
60177
|
-
|
|
60178
|
-
|
|
60179
|
-
|
|
60180
|
-
|
|
60176
|
+
index = -1
|
|
60177
|
+
|
|
60178
|
+
while (++index < node.children.length) {
|
|
60179
|
+
const child = node.children[index]
|
|
60180
|
+
// Uppercase to prevent prototype polution, injecting `constructor` or so.
|
|
60181
|
+
// Normalize because HTML is insensitive.
|
|
60182
|
+
const name =
|
|
60183
|
+
child.type === 'element' ? child.tagName.toUpperCase() : undefined
|
|
60184
|
+
// Before counting further elements:
|
|
60185
|
+
state.elementIndex = before.count
|
|
60186
|
+
state.typeIndex = name ? before.types.get(name) || 0 : 0
|
|
60187
|
+
// After counting all elements.
|
|
60188
|
+
state.elementCount = total.count
|
|
60189
|
+
state.typeCount = name ? total.types.get(name) : 0
|
|
60190
|
+
|
|
60191
|
+
// Only apply if this is a parent, this should be an element, but we check
|
|
60192
|
+
// for parents so that we delve into custom nodes too.
|
|
60193
|
+
if ('children' in child) {
|
|
60194
|
+
const forSibling = combine(fromParent, fromSibling)
|
|
60195
|
+
const nest = walk_one(state, forSibling, node.children[index], index, node)
|
|
60196
|
+
fromSibling = combine(nest.generalSibling, nest.adjacentSibling)
|
|
60197
|
+
}
|
|
60198
|
+
|
|
60199
|
+
// We found one thing, and one is enough.
|
|
60200
|
+
if (state.one && state.found) {
|
|
60201
|
+
break
|
|
60181
60202
|
}
|
|
60182
60203
|
|
|
60183
|
-
|
|
60204
|
+
count(before, node.children[index])
|
|
60184
60205
|
}
|
|
60185
60206
|
}
|
|
60186
60207
|
|
|
60187
|
-
// EXTERNAL MODULE: ../node_modules/css-selector-parser/lib/index.js
|
|
60188
|
-
var css_selector_parser_lib = __webpack_require__(510);
|
|
60189
|
-
;// CONCATENATED MODULE: ../node_modules/nth-check/lib/esm/parse.js
|
|
60190
|
-
// Following http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
|
|
60191
|
-
// Whitespace as per https://www.w3.org/TR/selectors-3/#lex is " \t\r\n\f"
|
|
60192
|
-
const parse_whitespace = new Set([9, 10, 12, 13, 32]);
|
|
60193
|
-
const ZERO = "0".charCodeAt(0);
|
|
60194
|
-
const NINE = "9".charCodeAt(0);
|
|
60195
60208
|
/**
|
|
60196
|
-
*
|
|
60209
|
+
* Apply selectors to an element.
|
|
60197
60210
|
*
|
|
60198
|
-
* @
|
|
60199
|
-
*
|
|
60200
|
-
* @
|
|
60201
|
-
|
|
60202
|
-
|
|
60203
|
-
|
|
60204
|
-
|
|
60205
|
-
|
|
60206
|
-
|
|
60207
|
-
|
|
60208
|
-
|
|
60209
|
-
|
|
60210
|
-
|
|
60211
|
-
|
|
60212
|
-
|
|
60213
|
-
|
|
60214
|
-
|
|
60215
|
-
|
|
60216
|
-
|
|
60217
|
-
|
|
60218
|
-
|
|
60219
|
-
|
|
60220
|
-
|
|
60221
|
-
|
|
60222
|
-
|
|
60223
|
-
|
|
60224
|
-
|
|
60225
|
-
|
|
60226
|
-
|
|
60227
|
-
}
|
|
60228
|
-
// Throw if there is anything else
|
|
60229
|
-
if (number === null || idx < formula.length) {
|
|
60230
|
-
throw new Error(`n-th rule couldn't be parsed ('${formula}')`);
|
|
60211
|
+
* @param {SelectState} state
|
|
60212
|
+
* Current state.
|
|
60213
|
+
* @param {Array<RuleSet>} rules
|
|
60214
|
+
* Rules to apply.
|
|
60215
|
+
* @param {Element} node
|
|
60216
|
+
* Element to apply rules to.
|
|
60217
|
+
* @param {number | undefined} index
|
|
60218
|
+
* Index of node in parent.
|
|
60219
|
+
* @param {Parent | undefined} parent
|
|
60220
|
+
* Parent of node.
|
|
60221
|
+
* @returns {Nest}
|
|
60222
|
+
* Further rules.
|
|
60223
|
+
*/
|
|
60224
|
+
function applySelectors(state, rules, node, index, parent) {
|
|
60225
|
+
/** @type {Nest} */
|
|
60226
|
+
const nestResult = {
|
|
60227
|
+
directChild: undefined,
|
|
60228
|
+
descendant: undefined,
|
|
60229
|
+
adjacentSibling: undefined,
|
|
60230
|
+
generalSibling: undefined
|
|
60231
|
+
}
|
|
60232
|
+
let selectorIndex = -1
|
|
60233
|
+
|
|
60234
|
+
while (++selectorIndex < rules.length) {
|
|
60235
|
+
const ruleSet = rules[selectorIndex]
|
|
60236
|
+
|
|
60237
|
+
// We found one thing, and one is enough.
|
|
60238
|
+
if (state.one && state.found) {
|
|
60239
|
+
break
|
|
60231
60240
|
}
|
|
60232
|
-
|
|
60233
|
-
|
|
60234
|
-
|
|
60235
|
-
|
|
60236
|
-
|
|
60237
|
-
|
|
60238
|
-
|
|
60239
|
-
|
|
60241
|
+
|
|
60242
|
+
// When shallow, we don’t allow nested rules.
|
|
60243
|
+
// Idea: we could allow a stack of parents?
|
|
60244
|
+
// Might get quite complex though.
|
|
60245
|
+
if (state.shallow && ruleSet.rule.rule) {
|
|
60246
|
+
throw new Error('Expected selector without nesting')
|
|
60247
|
+
}
|
|
60248
|
+
|
|
60249
|
+
// If this rule matches:
|
|
60250
|
+
if (test(ruleSet.rule, node, index, parent, state)) {
|
|
60251
|
+
const nest = ruleSet.rule.rule
|
|
60252
|
+
|
|
60253
|
+
// Are there more?
|
|
60254
|
+
if (nest) {
|
|
60255
|
+
/** @type {RuleSet} */
|
|
60256
|
+
const rule = {type: 'ruleSet', rule: nest}
|
|
60257
|
+
/** @type {keyof Nest} */
|
|
60258
|
+
const label =
|
|
60259
|
+
nest.nestingOperator === '+'
|
|
60260
|
+
? 'adjacentSibling'
|
|
60261
|
+
: nest.nestingOperator === '~'
|
|
60262
|
+
? 'generalSibling'
|
|
60263
|
+
: nest.nestingOperator === '>'
|
|
60264
|
+
? 'directChild'
|
|
60265
|
+
: 'descendant'
|
|
60266
|
+
add(nestResult, label, rule)
|
|
60267
|
+
} else {
|
|
60268
|
+
// We have a match!
|
|
60269
|
+
state.found = true
|
|
60270
|
+
|
|
60271
|
+
if (!state.results.includes(node)) {
|
|
60272
|
+
state.results.push(node)
|
|
60240
60273
|
}
|
|
60241
|
-
|
|
60274
|
+
}
|
|
60242
60275
|
}
|
|
60243
|
-
|
|
60244
|
-
|
|
60245
|
-
|
|
60246
|
-
|
|
60247
|
-
formula.charCodeAt(idx) >= ZERO &&
|
|
60248
|
-
formula.charCodeAt(idx) <= NINE) {
|
|
60249
|
-
value = value * 10 + (formula.charCodeAt(idx) - ZERO);
|
|
60250
|
-
idx++;
|
|
60251
|
-
}
|
|
60252
|
-
// Return `null` if we didn't read anything.
|
|
60253
|
-
return idx === start ? null : value;
|
|
60276
|
+
|
|
60277
|
+
// Descendant.
|
|
60278
|
+
if (ruleSet.rule.nestingOperator === null) {
|
|
60279
|
+
add(nestResult, 'descendant', ruleSet)
|
|
60254
60280
|
}
|
|
60255
|
-
|
|
60256
|
-
|
|
60257
|
-
|
|
60258
|
-
idx++;
|
|
60259
|
-
}
|
|
60281
|
+
// Adjacent.
|
|
60282
|
+
else if (ruleSet.rule.nestingOperator === '~') {
|
|
60283
|
+
add(nestResult, 'generalSibling', ruleSet)
|
|
60260
60284
|
}
|
|
60261
|
-
|
|
60262
|
-
|
|
60263
|
-
// EXTERNAL MODULE: ../node_modules/boolbase/index.js
|
|
60264
|
-
var boolbase = __webpack_require__(286);
|
|
60265
|
-
;// CONCATENATED MODULE: ../node_modules/nth-check/lib/esm/compile.js
|
|
60285
|
+
// Drop top-level nesting (`undefined`), direct child (`>`), adjacent sibling (`+`).
|
|
60286
|
+
}
|
|
60266
60287
|
|
|
60267
|
-
|
|
60268
|
-
* Returns a function that checks if an elements index matches the given rule
|
|
60269
|
-
* highly optimized to return the fastest solution.
|
|
60270
|
-
*
|
|
60271
|
-
* @param parsed A tuple [a, b], as returned by `parse`.
|
|
60272
|
-
* @returns A highly optimized function that returns whether an index matches the nth-check.
|
|
60273
|
-
* @example
|
|
60274
|
-
*
|
|
60275
|
-
* ```js
|
|
60276
|
-
* const check = nthCheck.compile([2, 3]);
|
|
60277
|
-
*
|
|
60278
|
-
* check(0); // `false`
|
|
60279
|
-
* check(1); // `false`
|
|
60280
|
-
* check(2); // `true`
|
|
60281
|
-
* check(3); // `false`
|
|
60282
|
-
* check(4); // `true`
|
|
60283
|
-
* check(5); // `false`
|
|
60284
|
-
* check(6); // `true`
|
|
60285
|
-
* ```
|
|
60286
|
-
*/
|
|
60287
|
-
function compile(parsed) {
|
|
60288
|
-
const a = parsed[0];
|
|
60289
|
-
// Subtract 1 from `b`, to convert from one- to zero-indexed.
|
|
60290
|
-
const b = parsed[1] - 1;
|
|
60291
|
-
/*
|
|
60292
|
-
* When `b <= 0`, `a * n` won't be lead to any matches for `a < 0`.
|
|
60293
|
-
* Besides, the specification states that no elements are
|
|
60294
|
-
* matched when `a` and `b` are 0.
|
|
60295
|
-
*
|
|
60296
|
-
* `b < 0` here as we subtracted 1 from `b` above.
|
|
60297
|
-
*/
|
|
60298
|
-
if (b < 0 && a <= 0)
|
|
60299
|
-
return boolbase.falseFunc;
|
|
60300
|
-
// When `a` is in the range -1..1, it matches any element (so only `b` is checked).
|
|
60301
|
-
if (a === -1)
|
|
60302
|
-
return (index) => index <= b;
|
|
60303
|
-
if (a === 0)
|
|
60304
|
-
return (index) => index === b;
|
|
60305
|
-
// When `b <= 0` and `a === 1`, they match any element.
|
|
60306
|
-
if (a === 1)
|
|
60307
|
-
return b < 0 ? boolbase.trueFunc : (index) => index >= b;
|
|
60308
|
-
/*
|
|
60309
|
-
* Otherwise, modulo can be used to check if there is a match.
|
|
60310
|
-
*
|
|
60311
|
-
* Modulo doesn't care about the sign, so let's use `a`s absolute value.
|
|
60312
|
-
*/
|
|
60313
|
-
const absA = Math.abs(a);
|
|
60314
|
-
// Get `b mod a`, + a if this is negative.
|
|
60315
|
-
const bMod = ((b % absA) + absA) % absA;
|
|
60316
|
-
return a > 1
|
|
60317
|
-
? (index) => index >= b && index % absA === bMod
|
|
60318
|
-
: (index) => index <= b && index % absA === bMod;
|
|
60288
|
+
return nestResult
|
|
60319
60289
|
}
|
|
60290
|
+
|
|
60320
60291
|
/**
|
|
60321
|
-
*
|
|
60322
|
-
*
|
|
60323
|
-
* If the sequence has an end, the returned function will return `null` after
|
|
60324
|
-
* the last index in the sequence.
|
|
60292
|
+
* Combine two lists, if needed.
|
|
60325
60293
|
*
|
|
60326
|
-
*
|
|
60327
|
-
* @returns A function that produces a sequence of indices.
|
|
60328
|
-
* @example <caption>Always increasing (2n+3)</caption>
|
|
60294
|
+
* This is optimized to create as few lists as possible.
|
|
60329
60295
|
*
|
|
60330
|
-
*
|
|
60331
|
-
*
|
|
60332
|
-
*
|
|
60333
|
-
* gen() // `1`
|
|
60334
|
-
* gen() // `3`
|
|
60335
|
-
* gen() // `5`
|
|
60336
|
-
* gen() // `8`
|
|
60337
|
-
* gen() // `11`
|
|
60338
|
-
* ```
|
|
60339
|
-
*
|
|
60340
|
-
* @example <caption>With end value (-2n+10)</caption>
|
|
60341
|
-
*
|
|
60342
|
-
* ```js
|
|
60343
|
-
*
|
|
60344
|
-
* const gen = nthCheck.generate([-2, 5]);
|
|
60345
|
-
*
|
|
60346
|
-
* gen() // 0
|
|
60347
|
-
* gen() // 2
|
|
60348
|
-
* gen() // 4
|
|
60349
|
-
* gen() // null
|
|
60350
|
-
* ```
|
|
60296
|
+
* @param {Array<RuleSet> | undefined} left
|
|
60297
|
+
* @param {Array<RuleSet> | undefined} right
|
|
60298
|
+
* @returns {Array<RuleSet>}
|
|
60351
60299
|
*/
|
|
60352
|
-
function
|
|
60353
|
-
|
|
60354
|
-
|
|
60355
|
-
|
|
60356
|
-
|
|
60357
|
-
|
|
60358
|
-
|
|
60359
|
-
|
|
60360
|
-
// Get `b mod a`
|
|
60361
|
-
const minValue = ((b % aPos) + aPos) % aPos;
|
|
60362
|
-
return () => {
|
|
60363
|
-
const val = minValue + aPos * n++;
|
|
60364
|
-
return val > b ? null : val;
|
|
60365
|
-
};
|
|
60366
|
-
}
|
|
60367
|
-
if (a === 0)
|
|
60368
|
-
return b < 0
|
|
60369
|
-
? // There are no result — always return `null`
|
|
60370
|
-
() => null
|
|
60371
|
-
: // Return `b` exactly once
|
|
60372
|
-
() => (n++ === 0 ? b : null);
|
|
60373
|
-
if (b < 0) {
|
|
60374
|
-
b += a * Math.ceil(-b / a);
|
|
60375
|
-
}
|
|
60376
|
-
return () => a * n++ + b;
|
|
60300
|
+
function combine(left, right) {
|
|
60301
|
+
return left && right && left.length > 0 && right.length > 0
|
|
60302
|
+
? [...left, ...right]
|
|
60303
|
+
: left && left.length > 0
|
|
60304
|
+
? left
|
|
60305
|
+
: right && right.length > 0
|
|
60306
|
+
? right
|
|
60307
|
+
: walk_empty
|
|
60377
60308
|
}
|
|
60378
|
-
//# sourceMappingURL=compile.js.map
|
|
60379
|
-
;// CONCATENATED MODULE: ../node_modules/nth-check/lib/esm/index.js
|
|
60380
|
-
|
|
60381
|
-
|
|
60382
60309
|
|
|
60383
60310
|
/**
|
|
60384
|
-
*
|
|
60385
|
-
* Combination of {@link parse} and {@link compile}.
|
|
60311
|
+
* Add a rule to a nesting map.
|
|
60386
60312
|
*
|
|
60387
|
-
*
|
|
60388
|
-
*
|
|
60389
|
-
*
|
|
60390
|
-
* whether or not the passed _index_ matches the formula.
|
|
60391
|
-
*
|
|
60392
|
-
* Note: The nth-rule starts counting at `1`, the returned function at `0`.
|
|
60393
|
-
*
|
|
60394
|
-
* @param formula The formula to compile.
|
|
60395
|
-
* @example
|
|
60396
|
-
* const check = nthCheck("2n+3");
|
|
60397
|
-
*
|
|
60398
|
-
* check(0); // `false`
|
|
60399
|
-
* check(1); // `false`
|
|
60400
|
-
* check(2); // `true`
|
|
60401
|
-
* check(3); // `false`
|
|
60402
|
-
* check(4); // `true`
|
|
60403
|
-
* check(5); // `false`
|
|
60404
|
-
* check(6); // `true`
|
|
60313
|
+
* @param {Nest} nest
|
|
60314
|
+
* @param {keyof Nest} field
|
|
60315
|
+
* @param {RuleSet} rule
|
|
60405
60316
|
*/
|
|
60406
|
-
function
|
|
60407
|
-
|
|
60317
|
+
function add(nest, field, rule) {
|
|
60318
|
+
const list = nest[field]
|
|
60319
|
+
if (list) {
|
|
60320
|
+
list.push(rule)
|
|
60321
|
+
} else {
|
|
60322
|
+
nest[field] = [rule]
|
|
60323
|
+
}
|
|
60408
60324
|
}
|
|
60325
|
+
|
|
60409
60326
|
/**
|
|
60410
|
-
*
|
|
60411
|
-
* Combination of {@link parse} and {@link generate}.
|
|
60412
|
-
*
|
|
60413
|
-
* @param formula The formula to compile.
|
|
60414
|
-
* @returns A function that produces a sequence of indices.
|
|
60415
|
-
* @example <caption>Always increasing</caption>
|
|
60416
|
-
*
|
|
60417
|
-
* ```js
|
|
60418
|
-
* const gen = nthCheck.sequence('2n+3')
|
|
60419
|
-
*
|
|
60420
|
-
* gen() // `1`
|
|
60421
|
-
* gen() // `3`
|
|
60422
|
-
* gen() // `5`
|
|
60423
|
-
* gen() // `8`
|
|
60424
|
-
* gen() // `11`
|
|
60425
|
-
* ```
|
|
60327
|
+
* Count a node.
|
|
60426
60328
|
*
|
|
60427
|
-
* @
|
|
60428
|
-
*
|
|
60429
|
-
*
|
|
60430
|
-
*
|
|
60431
|
-
*
|
|
60432
|
-
*
|
|
60433
|
-
* gen() // 0
|
|
60434
|
-
* gen() // 2
|
|
60435
|
-
* gen() // 4
|
|
60436
|
-
* gen() // null
|
|
60437
|
-
* ```
|
|
60329
|
+
* @param {Counts} counts
|
|
60330
|
+
* Counts.
|
|
60331
|
+
* @param {Node} node
|
|
60332
|
+
* Node (we’re looking for elements).
|
|
60333
|
+
* @returns {void}
|
|
60334
|
+
* Nothing.
|
|
60438
60335
|
*/
|
|
60439
|
-
function
|
|
60440
|
-
|
|
60336
|
+
function count(counts, node) {
|
|
60337
|
+
if (node.type === 'element') {
|
|
60338
|
+
// Uppercase to prevent prototype polution, injecting `constructor` or so.
|
|
60339
|
+
// Normalize because HTML is insensitive.
|
|
60340
|
+
const name = node.tagName.toUpperCase()
|
|
60341
|
+
const count = (counts.types.get(name) || 0) + 1
|
|
60342
|
+
counts.count++
|
|
60343
|
+
counts.types.set(name, count)
|
|
60344
|
+
}
|
|
60441
60345
|
}
|
|
60442
|
-
|
|
60346
|
+
|
|
60347
|
+
// EXTERNAL MODULE: ../node_modules/css-selector-parser/lib/index.js
|
|
60348
|
+
var css_selector_parser_lib = __webpack_require__(510);
|
|
60443
60349
|
;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/parse.js
|
|
60444
60350
|
/**
|
|
60445
|
-
* @typedef {import('./types.js').Selector} Selector
|
|
60446
60351
|
* @typedef {import('./types.js').Selectors} Selectors
|
|
60447
60352
|
* @typedef {import('./types.js').RuleSet} RuleSet
|
|
60448
|
-
* @typedef {import('./types.js').Rule} Rule
|
|
60449
|
-
* @typedef {import('./types.js').RulePseudo} RulePseudo
|
|
60450
|
-
* @typedef {import('./types.js').RulePseudoNth} RulePseudoNth
|
|
60451
60353
|
*/
|
|
60452
60354
|
|
|
60453
60355
|
|
|
60454
60356
|
|
|
60455
|
-
|
|
60456
|
-
|
|
60457
|
-
/** @type {import('nth-check').default} */
|
|
60458
|
-
// @ts-expect-error
|
|
60459
|
-
const parse_nthCheck = nthCheck["default"] || nthCheck
|
|
60460
|
-
|
|
60461
|
-
const nth = new Set([
|
|
60462
|
-
'nth-child',
|
|
60463
|
-
'nth-last-child',
|
|
60464
|
-
'nth-of-type',
|
|
60465
|
-
'nth-last-of-type'
|
|
60466
|
-
])
|
|
60467
|
-
|
|
60468
60357
|
const parse_parser = new css_selector_parser_lib/* CssSelectorParser */.N()
|
|
60469
60358
|
|
|
60470
|
-
// @ts-expect-error: hush.
|
|
60471
|
-
const parse_compile = zwitch('type', {handlers: {selectors: parse_selectors, ruleSet: parse_ruleSet, rule: parse_rule}})
|
|
60472
|
-
|
|
60473
60359
|
parse_parser.registerAttrEqualityMods('~', '|', '^', '$', '*')
|
|
60474
60360
|
parse_parser.registerSelectorPseudos('any', 'matches', 'not', 'has')
|
|
60475
60361
|
parse_parser.registerNestingOperators('>', '+', '~')
|
|
60476
60362
|
|
|
60477
60363
|
/**
|
|
60478
60364
|
* @param {string} selector
|
|
60479
|
-
* @returns {
|
|
60365
|
+
* @returns {Selectors | RuleSet | null}
|
|
60480
60366
|
*/
|
|
60481
60367
|
function lib_parse_parse(selector) {
|
|
60482
60368
|
if (typeof selector !== 'string') {
|
|
60483
60369
|
throw new TypeError('Expected `string` as selector, not `' + selector + '`')
|
|
60484
60370
|
}
|
|
60485
60371
|
|
|
60486
|
-
|
|
60487
|
-
return parse_compile(parse_parser.parse(selector))
|
|
60488
|
-
}
|
|
60489
|
-
|
|
60490
|
-
/**
|
|
60491
|
-
* @param {Selectors} query
|
|
60492
|
-
* @returns {Selectors}
|
|
60493
|
-
*/
|
|
60494
|
-
function parse_selectors(query) {
|
|
60495
|
-
let index = -1
|
|
60496
|
-
|
|
60497
|
-
while (++index < query.selectors.length) {
|
|
60498
|
-
parse_compile(query.selectors[index])
|
|
60499
|
-
}
|
|
60500
|
-
|
|
60501
|
-
return query
|
|
60502
|
-
}
|
|
60503
|
-
|
|
60504
|
-
/**
|
|
60505
|
-
* @param {RuleSet} query
|
|
60506
|
-
* @returns {Rule}
|
|
60507
|
-
*/
|
|
60508
|
-
function parse_ruleSet(query) {
|
|
60509
|
-
return parse_rule(query.rule)
|
|
60510
|
-
}
|
|
60511
|
-
|
|
60512
|
-
/**
|
|
60513
|
-
* @param {Rule} query
|
|
60514
|
-
* @returns {Rule}
|
|
60515
|
-
*/
|
|
60516
|
-
function parse_rule(query) {
|
|
60517
|
-
const pseudos = query.pseudos || []
|
|
60518
|
-
let index = -1
|
|
60519
|
-
|
|
60520
|
-
while (++index < pseudos.length) {
|
|
60521
|
-
const pseudo = pseudos[index]
|
|
60522
|
-
|
|
60523
|
-
if (nth.has(pseudo.name)) {
|
|
60524
|
-
// @ts-expect-error Patch a non-primitive type.
|
|
60525
|
-
pseudo.value = parse_nthCheck(pseudo.value)
|
|
60526
|
-
// @ts-expect-error Patch a non-primitive type.
|
|
60527
|
-
pseudo.valueType = 'function'
|
|
60528
|
-
}
|
|
60529
|
-
}
|
|
60530
|
-
|
|
60531
|
-
parse_compile(query.rule)
|
|
60532
|
-
|
|
60533
|
-
return query
|
|
60372
|
+
return parse_parser.parse(selector)
|
|
60534
60373
|
}
|
|
60535
60374
|
|
|
60536
60375
|
;// CONCATENATED MODULE: ../node_modules/hast-util-select/index.js
|
|
60537
60376
|
/**
|
|
60538
60377
|
* @typedef {import('./lib/types.js').Element} Element
|
|
60539
|
-
* @typedef {import('./lib/types.js').
|
|
60378
|
+
* @typedef {import('./lib/types.js').Node} Node
|
|
60540
60379
|
* @typedef {import('./lib/types.js').Space} Space
|
|
60380
|
+
* @typedef {import('./lib/types.js').SelectState} SelectState
|
|
60541
60381
|
*/
|
|
60542
60382
|
|
|
60543
60383
|
|
|
60544
60384
|
|
|
60545
60385
|
|
|
60386
|
+
|
|
60546
60387
|
/**
|
|
60388
|
+
* Check that the given `node` matches `selector`.
|
|
60389
|
+
*
|
|
60390
|
+
* This only checks the element itself, not the surrounding tree.
|
|
60391
|
+
* Thus, nesting in selectors is not supported (`p b`, `p > b`), neither are
|
|
60392
|
+
* selectors like `:first-child`, etc.
|
|
60393
|
+
* This only checks that the given element matches the selector.
|
|
60394
|
+
*
|
|
60547
60395
|
* @param {string} selector
|
|
60548
|
-
*
|
|
60549
|
-
* @param {
|
|
60396
|
+
* CSS selector, such as (`h1`, `a, b`).
|
|
60397
|
+
* @param {Node | null | undefined} [node]
|
|
60398
|
+
* Node that might match `selector`, should be an element.
|
|
60399
|
+
* @param {Space | null | undefined} [space='html']
|
|
60400
|
+
* Name of namespace (`'svg'` or `'html'`).
|
|
60550
60401
|
* @returns {boolean}
|
|
60402
|
+
* Whether `node` matches `selector`.
|
|
60551
60403
|
*/
|
|
60552
60404
|
function hast_util_select_matches(selector, node, space) {
|
|
60553
|
-
|
|
60554
|
-
|
|
60555
|
-
|
|
60405
|
+
const state = createState(selector, node, space)
|
|
60406
|
+
state.one = true
|
|
60407
|
+
state.shallow = true
|
|
60408
|
+
walk(state, node || undefined)
|
|
60409
|
+
return state.results.length > 0
|
|
60556
60410
|
}
|
|
60557
60411
|
|
|
60558
60412
|
/**
|
|
60413
|
+
* Select the first element that matches `selector` in the given `tree`.
|
|
60414
|
+
* Searches the tree in *preorder*.
|
|
60415
|
+
*
|
|
60559
60416
|
* @param {string} selector
|
|
60560
|
-
*
|
|
60561
|
-
* @param {
|
|
60562
|
-
*
|
|
60563
|
-
|
|
60564
|
-
|
|
60565
|
-
|
|
60417
|
+
* CSS selector, such as (`h1`, `a, b`).
|
|
60418
|
+
* @param {Node | null | undefined} [tree]
|
|
60419
|
+
* Tree to search.
|
|
60420
|
+
* @param {Space | null | undefined} [space='html']
|
|
60421
|
+
* Name of namespace (`'svg'` or `'html'`).
|
|
60422
|
+
* @returns {Element | null}
|
|
60423
|
+
* First element in `tree` that matches `selector` or `null` if nothing is
|
|
60424
|
+
* found.
|
|
60425
|
+
* This could be `tree` itself.
|
|
60426
|
+
*/
|
|
60427
|
+
function hast_util_select_select(selector, tree, space) {
|
|
60428
|
+
const state = createState(selector, tree, space)
|
|
60429
|
+
state.one = true
|
|
60430
|
+
walk(state, tree || undefined)
|
|
60431
|
+
// To do in major: return `undefined` instead.
|
|
60432
|
+
return state.results[0] || null
|
|
60566
60433
|
}
|
|
60567
60434
|
|
|
60568
60435
|
/**
|
|
60436
|
+
* Select all elements that match `selector` in the given `tree`.
|
|
60437
|
+
* Searches the tree in *preorder*.
|
|
60438
|
+
*
|
|
60569
60439
|
* @param {string} selector
|
|
60570
|
-
*
|
|
60571
|
-
* @param {
|
|
60440
|
+
* CSS selector, such as (`h1`, `a, b`).
|
|
60441
|
+
* @param {Node | null | undefined} [tree]
|
|
60442
|
+
* Tree to search.
|
|
60443
|
+
* @param {Space | null | undefined} [space='html']
|
|
60444
|
+
* Name of namespace (`'svg'` or `'html'`).
|
|
60572
60445
|
* @returns {Array<Element>}
|
|
60446
|
+
* Elements in `tree` that match `selector`.
|
|
60447
|
+
* This could include `tree` itself.
|
|
60573
60448
|
*/
|
|
60574
|
-
function selectAll(selector,
|
|
60575
|
-
|
|
60449
|
+
function selectAll(selector, tree, space) {
|
|
60450
|
+
const state = createState(selector, tree, space)
|
|
60451
|
+
walk_walk(state, tree || undefined)
|
|
60452
|
+
return state.results
|
|
60453
|
+
}
|
|
60454
|
+
|
|
60455
|
+
/**
|
|
60456
|
+
* @param {string} selector
|
|
60457
|
+
* Tree to search.
|
|
60458
|
+
* @param {Node | null | undefined} [tree]
|
|
60459
|
+
* Tree to search.
|
|
60460
|
+
* @param {Space | null | undefined} [space='html']
|
|
60461
|
+
* Name of namespace (`'svg'` or `'html'`).
|
|
60462
|
+
* @returns {SelectState} SelectState
|
|
60463
|
+
*/
|
|
60464
|
+
function createState(selector, tree, space) {
|
|
60465
|
+
return {
|
|
60466
|
+
// State of the query.
|
|
60467
|
+
rootQuery: queryToSelectors(lib_parse_parse(selector)),
|
|
60468
|
+
results: [],
|
|
60469
|
+
// @ts-expect-error assume elements.
|
|
60470
|
+
scopeElements: tree ? (tree.type === 'root' ? tree.children : [tree]) : [],
|
|
60471
|
+
one: false,
|
|
60472
|
+
shallow: false,
|
|
60473
|
+
found: false,
|
|
60474
|
+
// State in the tree.
|
|
60475
|
+
schema: space === 'svg' ? property_information_svg : property_information_html,
|
|
60476
|
+
language: undefined,
|
|
60477
|
+
direction: 'ltr',
|
|
60478
|
+
editableOrEditingHost: false,
|
|
60479
|
+
typeIndex: undefined,
|
|
60480
|
+
elementIndex: undefined,
|
|
60481
|
+
typeCount: undefined,
|
|
60482
|
+
elementCount: undefined
|
|
60483
|
+
}
|
|
60576
60484
|
}
|
|
60577
60485
|
|
|
60578
60486
|
;// CONCATENATED MODULE: ../node_modules/rehype-rewrite/lib/index.js
|