Skip to content

[css-typed-om] Why is StylePropertyMap.get defined to return undefined instead of null? #848

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

Closed
dead-claudia opened this issue Dec 16, 2018 · 2 comments

Comments

@dead-claudia
Copy link

In this section and the associated IDL, StylePropertyMap.get is defined to return either undefined or the resulting CSSStyleProperty. This is inconsistent with the DOM and HTML specs, which use the optional type T? which means T or null.

It's very explicit in the spec it means to use undefined, even though it doesn't explain its departure from null and T?, so I was just wondering what the reasoning behind it was.

@dead-claudia
Copy link
Author

Another thing worth mentioning is the fact CSS and DOM are still significantly used in non-web, non-JS contexts. JS is unique in having two null values instead of one - languages like Java don't have this, and I could see this spec becoming useful in those circles, too.

@tabatkins
Copy link
Member

The JS Map object returns undefined from those operations. The spec intentionally matches that behavior. I consider DOM's usage of null for similar flagging purposes a legacy mistake; it's a result of Java only having null, and so WebIDL (in its early "let's pretend we're writing APIs for both JS and Java" form) naturally defaulted to making null easy to use.

See whatwg/webidl#60 for further discussion of the more general issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants