-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve exception messages when a token is not found (#73)
In most cases, a full selector is parsed as a token, and if not, we report the character we are at as invalid. While better context is provided in exceptions for tokens that are fully parsed and validated, when we don't parse a token, very little is conveyed back to the user. There are only a few types of selectors allowed in CSS: tags, attr, class, id, pseudo-class, pseudo-elements, and combinators. You can have variations of these, but that is it. We cover most of these cases already with decent context, but there are still a few case that are just reported as invalid characters. Moving forward, we will see if the invalid character represents the start of one of the basic, supported types. Only attr, class, id, and pseudo-(class|element) really fall into the category that would generate one of these ambiguous exceptions, so identify their starting character and raise an appropriate "malformed" selector exception. Also remove unnecessary "+" in PAT_PSEUDO_CLASS.
- Loading branch information
1 parent
73b460a
commit 9fb1f46
Showing
3 changed files
with
36 additions
and
5 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