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

[cssom] Should make it clear that static functions on CSS are Window-scoped #180

Closed
tabatkins opened this issue Jun 9, 2016 · 8 comments
Assignees

Comments

@tabatkins
Copy link
Member

In w3c/css-houdini-drafts#216 there's some confusion about what scope the functions on the CSS interface should have - are they document-specific (somehow), window-specific, or global across the browser?

The intention is always that these are window-specific. The spec should have some clarifying text for this.

@tabatkins tabatkins added the cssom-1 Current Work label Jun 9, 2016
@dholbert
Copy link
Member

dholbert commented Jun 9, 2016

(Though if it doesn't matter, maybe they should be document-specific (instead of window-specific), since object-lifetime is more interoperable for document than for window. So if lifetime/scope is what we're trying to hammer down here, it'd be better to chain off of an object whose lifetime is already interoperable.)

@zcorpan
Copy link
Member

zcorpan commented Jun 10, 2016

Isn't this defined by WebIDL? Same as any other interface?

@dholbert
Copy link
Member

dholbert commented Jun 10, 2016

Isn't this defined by WebIDL? Same as any other interface?

I don't think so. Note that we're talking about static functions here. WebIDL says this about static functions:

A static operation is one that is not called on a particular instance
of the interface on which it is declared, and is instead associated
with the interface itself.

https://www.w3.org/TR/WebIDL/#idl-static-operations

When such a function is specced as...

  • changing state in a way that influences behavior (as with houdini CSS.registerProperty)
  • depending on state (as with CSS.supports in the face of possible calls to registerProperty which should influence supported styles)

...I don't think the WebIDL spec or Houdini Properties & Values says anything right now about where (or how long) that "static" state lives. WebIDL talks about state associated with instances of interfaces, but I don't see anything about state associated with the interface itself for static functions to read/modify.

@tabatkins
Copy link
Member Author

Domenic just posted an excellent breakdown of what all the globals are for a page. This indicates that we (a) probably can't define this globally, but (b) have a pretty clear answer on what to refer to for any given API.

@zcorpan
Copy link
Member

zcorpan commented Jun 23, 2016

cc @domenic

@domenic
Copy link
Collaborator

domenic commented Jun 23, 2016

You have two choices here, basically depending on whether you think of CSS as a state-carrying registry, or a namespace object full of functions.

The distinguishing code is window1.CSS.registerProperty.call(window2.CSS, ...).

  • If CSS is a state-carrying registry, then this should register the property on window2.
  • If CSS is just a bag of functions, it doesn't matter what the this value you call them with is, so this should register the property on window1.

To access window1 you'd use "this CSS interface object's relevant global object". (Alternately you could store the state on the CSS interface object itself, instead of grabbing a window.) "the current global object"

To access window2 you'd use "the current global object""this CSS interface object's relevant global object". (Alternately you could store the state on the CSS interface object itself, instead of grabbing a window.).

In both cases you could add "...'s associated Document" if you wanted things to go away during document.open(), which replaces the Document but keeps the Window.

@tabatkins
Copy link
Member Author

CSS is just a namespace object. There should be absolutely zero difference between window.CSS.foo() and an alternative window.CSSFoo(). So we should be using the relevant global object for everything.

We probably want to attach to the document itself, so we actually want "this CSS interface's relevant global object's associated Document".

@domenic
Copy link
Collaborator

domenic commented Jun 23, 2016

So we should be using the relevant global object for everything.

I'm sorry, I got it backwards in my post. You want the "current global object". My bullets were correct but my "To access" was wrong. Let me do some ins/dels.

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

4 participants