-
-
Notifications
You must be signed in to change notification settings - Fork 72
Fix parser functions #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix parser functions #198
Conversation
* TYPES values have been changed to allow bitwise operations. * Fixed valueType() function. * Other parser functions have been modified to match the changes to the valueType() function.
Thanks as always! I'm happy to continue merging with only light review, as you are quickly becoming the person most knowledgeable about this package. However, as before, can you help provide more of an overview of what this PR accomplishes? First, does this have any impact on observable behavior in jsdom? Or does it only impact the "internal" functions like If it is only for the internal functions, why are these changes improvements? What was wrong with the previous behavior, and what does the new behavior help with? I'm particularly a bit surprised by the introduction of new types I'm also unsure why we would want the type to be compatible with bitwise operations. Does this mean values can have multiple types? What is an example of when that would be useful? |
It does have some impacts.
I think the TYPES.FOO constants were used in place of tokens, e.g. <length>, <percent>, <string> etc.
One of the new constant added this time is Another new constant is And since they are numeric constant values, I thought it would be better to take advantage of that, so decided to use bitwise. I believe this change has at least two benefits that lead to improved readability:
|
Thanks for explaining!
The better fix for this would be to update the setter code to have Web IDL-conformant behavior: convert undefined (and null) to empty string at the boundary. I don't think undefined or null should ever reach the internals of the library.
In my opinion, if you don't need to return multiple types at once, then using a bitwise pattern reduces readability, by requiring the reader to be familiar with bitwise operations and what they mean. It is fewer characters, but those characters are harder to understand. It also will be confusing for people who are used to bitwise enums meaning that a value can have multiple types at once. Basically, this usage of bitwise enums is very nonstandard. So I'd prefer that we stick with normal equality operations, instead of using bitwise ones. |
I completely agree, but doing so would require a lot of fixes. Also, there are many properties that are missing. I feel it would be better to tackle the files under
Got it. |
My thoughts on this project:
|
to allow bitwise operations.lib/parsers.js
).This should fix #189, closes #190