-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit updates `css-selector-parser`, which is completely different. You’ll get some different errors if you do weird things. Otherwise, this changes: * change to throw on empty selector * change to on invalid attribute selectors such as `[a=b,c]`, use `[a="b,c"]` instead * remove `any`, `matches`: use `:is()` instead
- Loading branch information
Showing
16 changed files
with
388 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
/** | ||
* @typedef {import('./types.js').Rule} Rule | ||
* @typedef {import('css-selector-parser').AstRule} AstRule | ||
* @typedef {import('./types.js').Element} Element | ||
*/ | ||
|
||
import {ok as assert} from 'devlop' | ||
|
||
/** | ||
* Check whether an element has an ID. | ||
* | ||
* @param {Rule} query | ||
* @param {AstRule} query | ||
* @param {Element} element | ||
* @returns {boolean} | ||
*/ | ||
export function id(query, element) { | ||
return Boolean(element.properties && element.properties.id === query.id) | ||
assert(query.ids, 'expected `ids`') | ||
const id = query.ids[query.ids.length - 1] | ||
return Boolean(element.properties && element.properties.id === id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
/** | ||
* @typedef {import('./types.js').Rule} Rule | ||
* @typedef {import('css-selector-parser').AstRule} AstRule | ||
* @typedef {import('./types.js').Element} Element | ||
*/ | ||
|
||
import {ok as assert} from 'devlop' | ||
|
||
/** | ||
* Check whether an element has a tag name. | ||
* | ||
* @param {Rule} query | ||
* @param {AstRule} query | ||
* @param {Element} element | ||
* @returns {boolean} | ||
*/ | ||
export function name(query, element) { | ||
return query.tagName === '*' || query.tagName === element.tagName | ||
assert(query.tag, 'expected `tag`') | ||
return query.tag.type === 'WildcardTag' || query.tag.name === element.tagName | ||
} |
Oops, something went wrong.