-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLEANUP] Add CssInliner::querySelectorAll method
This `private` method provides functionality that is used in three separate places (albeit a one-liner), and includes taking care of exception handling according to the debug mode setting. The new method and parameter names match the equivalent in the [Web API]( https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll ). There will be a tiny performance impact due to additional method calls. But the benefits include code re-use and common error handling. Also add `ensureNodeIsElement` method for use with the result from `querySelectorAll` to ensure type safety. `querySelectorAll` should always return a `DOMNodeList` of `DOMElement`s. But this cannot be guaranteed if there is a bug in CssSelector whereby it returns an XPath expression which may match non-element nodes. And it would (probably) be sub-optimal for `querySelectorAll` to have an extra loop checking this, when it can be done in the caller's loop over the returned data.
- Loading branch information
Showing
2 changed files
with
77 additions
and
37 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