-
-
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.
- Loading branch information
Showing
7 changed files
with
36 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
/** | ||
* @typedef {import('css-selector-parser').AstRule} AstRule | ||
* @typedef {import('css-selector-parser').AstId} AstId | ||
* | ||
* @typedef {import('hast').Element} Element | ||
*/ | ||
|
||
import {ok as assert} from 'devlop' | ||
// Workaround to show references to above types in VS Code. | ||
'' | ||
|
||
/** | ||
* Check whether an element has an ID. | ||
* | ||
* @param {AstRule} query | ||
* @param {AstId} query | ||
* AST rule (with `ids`). | ||
* @param {Element} element | ||
* Element. | ||
* @returns {boolean} | ||
* Whether `element` matches `query`. | ||
*/ | ||
export function id(query, element) { | ||
const ids = query.ids | ||
assert(ids, 'expected `ids`') | ||
return ids.length === 1 && element.properties.id === ids[0] | ||
return element.properties.id === query.name | ||
} |
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,22 +1,22 @@ | ||
/** | ||
* @typedef {import('css-selector-parser').AstRule} AstRule | ||
* @typedef {import('css-selector-parser').AstTagName} AstTagName | ||
* | ||
* @typedef {import('hast').Element} Element | ||
*/ | ||
|
||
import {ok as assert} from 'devlop' | ||
// Workaround to show references to above types in VS Code. | ||
'' | ||
|
||
/** | ||
* Check whether an element has a tag name. | ||
* | ||
* @param {AstRule} query | ||
* @param {AstTagName} query | ||
* AST rule (with `tag`). | ||
* @param {Element} element | ||
* Element. | ||
* @returns {boolean} | ||
* Whether `element` matches `query`. | ||
*/ | ||
export function name(query, element) { | ||
assert(query.tag, 'expected `tag`') | ||
return query.tag.type === 'WildcardTag' || query.tag.name === element.tagName | ||
return query.name === element.tagName | ||
} |
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