Skip to content
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

Add namespaces #121

Merged
merged 4 commits into from
Aug 25, 2016
Merged

Add namespaces #121

merged 4 commits into from
Aug 25, 2016

Conversation

domenic
Copy link
Member

@domenic domenic commented May 11, 2016

This adds the concept of namespaces, as discussed in whatwg/console#3 (starting especially around whatwg/console#3 (comment)). They can only contain regular operations.

The ES binding for namespaces here is written in a fully modern style, and so differs slightly from similar prose for interfaces' ES binding. It is hoped that it can provide a template for eventually updating interfaces' ES binding to modern ES.

@zcorpan
Copy link
Member

zcorpan commented May 12, 2016

For CSS at least I think we need partial namespace CSS { ... }, since different specs add stuff to it. Is that supported?

@domenic
Copy link
Member Author

domenic commented May 12, 2016

No, I was lazy. I can add it...

@zcorpan
Copy link
Member

zcorpan commented May 12, 2016

👍

Filed https://www.w3.org/Bugs/Public/show_bug.cgi?id=29623 for CSS

@domenic
Copy link
Member Author

domenic commented May 13, 2016

Added partial namespaces and fixed a few things I noticed were missing. Left it as a separate commit in case anyone wants to see the sausage being made.

<p>
An ECMAScript implementation would then expose a global property named
<code>VectorUtils</code> which was a simple object (with prototype
<a>%ObjectPrototype%</a>) with non-enumerable data properties for each declared
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different from interfaces, where things are enumerable, right? Why the change? Changing the behavior of CSS and console in this way may or may not be web-compatible... (yes, I just checked and all the stuff on console is enumerable in at least Safari, Chrome, and Firefox).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was torn on this. Safari indicated a desire to match ES's namespaces (Math, Reflect, JSON) which are not. And, Object.keys(console) currently returns [] because of the prototype separation; this preserves that. To me, it seems more likely people are depending on Object.keys(console) being empty (so that e.g. Object.keys(console) returns any methods they themselves added), than that they are depending on Object.getOwnPropertyDescriptor(console, "log").enumerable being true.

I guess maybe they are using for-in though, which does change.

I should probably flip this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for-in is the case that worries me, compat-wise.

@domenic
Copy link
Member Author

domenic commented May 13, 2016

Updated based on code review comments, including changing to enumerable.

@zcorpan
Copy link
Member

zcorpan commented May 13, 2016

cc @esprehn

@bzbarsky
Copy link
Collaborator

@domenic it's hard to tell from the diff; does this PR update http://heycam.github.io/webidl/#dfn-named-definition ?

@bzbarsky
Copy link
Collaborator

Also, does it update the

Within the set of IDL fragments that a given implementation supports, the identifier of every interface, dictionary, enumeration, callback function and typedef MUST NOT be the same as the identifier of any other interface, dictionary, enumeration, callback function or typedef.

language in http://heycam.github.io/webidl/#idl-names ?

@domenic
Copy link
Member Author

domenic commented Jul 15, 2016

@domenic it's hard to tell from the diff; does this PR update http://heycam.github.io/webidl/#dfn-named-definition ?

Yes

Also, does it update the ... language in http://heycam.github.io/webidl/#idl-names ?

Nope, missed that one. Pushed a rebased and squashed commit with that included.


The larger question we have before merging and using this for Console is what to do about the fact that console, for legacy reasons, needs an empty [[Prototype]] between it and Object.prototype.

  • Do we build that into the definition of namespaces? (Hopefully not)
  • Do we create an in-IDL way of expressing that one-off situation, say an extended attribute?
  • Do we let the console spec add an exotic binding-level requirement that transcends Web IDL?

If I had some guidance on that I think we'd be ready to merge and use this...

@bzbarsky
Copy link
Collaborator

In Gecko, I implemented an extended attribute for the console thing. How we should spec it.... I'm not sure. :(

@domenic
Copy link
Member Author

domenic commented Jul 15, 2016

I guess I lean toward a one-off requirement in the console spec? In which case this should be mergeable...

@domenic
Copy link
Member Author

domenic commented Aug 24, 2016

@bzbarsky @heycam ping on merging this? I can rebase if I am assured it will get merged soon, but I'm not eager to do so if it's just going to rot again...

Also same question on #133 and #146.

<div class='note'>
<p>
As with partial interface definitions, partial namespace definitions are intended for
use as a specification editorial aide, allowing the definition of an interface to be
Copy link
Collaborator

@bzbarsky bzbarsky Aug 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the definition of a namespace"

namespace and one of its namespace members, then the namespace member's
<a class='dfnref' href='#dfn-exposure-set'>exposure set</a>
<span class='rfc2119'>MUST</span> be a subset of the namespace's
<a class='dfnref' href='#dfn-exposure-set'>exposure set</a>.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec seems to be missing an obvious requirement for interface that we should add, and add a corresponding one for namespaces: "If [Exposed] appears on a partial interface, then the partial interface's exposure set MUST be a subset of the interface's exposure set." Otherwise we would be allowing this:

interface Foo {
};
[Exposed=Worker]
partial interface Foo {
  void func();
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to square that with "Any extended attribute specified on a partial interface definition is considered to appear on the interface itself." It seems like the above snippet somehow makes Foo only exposed in Workers, per that text... (This is similar to my above reply.)

@bzbarsky
Copy link
Collaborator

Sorry, it wasn't clear to me what the state of this was.

I guess if the plan is to add an extended attribute in the console spec that changes the behavior then I'm OK with merging this, modulo the comments above...

This adds the concept of namespaces, as discussed in whatwg/console#3 (starting especially around whatwg/console#3 (comment)). They can only contain regular operations.

The ES binding for namespaces here is written in a fully modern style, and so differs slightly from similar prose for interfaces' ES binding. It is hoped that it can provide a template for eventually updating interfaces' ES binding to modern ES.
- Missing some [SecureContext] stuff
- Not yet addressed the operation-creation stuff
It doesn't read quite right to me, but let's keep it as-is for now and investigate any issues in #153.
@domenic
Copy link
Member Author

domenic commented Aug 25, 2016

OK, I think everything is addressed; thanks for the careful review. Clearly partial namespaces were added later and I didn't go through and find all the places they needed to be accounted for. The follow-up issues of #154 and #153 are filed, and the "creating an operation function" algorithm is moved into #es-operations with a note about how we'll consolidate soon.

I uploaded as separate commits for easier reviewing/verification, but I can squash if @heycam hasn't enabled squashing-from-GitHub-UI on this repo.

@bzbarsky
Copy link
Collaborator

OK, I skimmed over the update commits and looks reasonable at first glance. I wish we had a real review system... ;)

@bzbarsky bzbarsky merged commit df8c9c4 into whatwg:gh-pages Aug 25, 2016
zcorpan added a commit to zcorpan/csswg-drafts that referenced this pull request Sep 2, 2016
Web IDL added support for namespaces in
whatwg/webidl#121

elementSources in css-images-4 is commented out for now because
IDL namespaces don't support attributes yet, see w3c#428.

Fixes part of https://www.w3.org/Bugs/Public/show_bug.cgi?id=29623
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants