w3c / css-houdini-drafts

Mirror of https://hg.css-houdini.org/drafts
https://drafts.css-houdini.org/
Other
1.84k stars 141 forks source link

[other] We should create a CSS Dependencies spec #44

Open FremyCompany opened 9 years ago

FremyCompany commented 9 years ago

This specification would define how things like CustomPaint, the ApplyHook and other things like CustomLayout declaratively define their dependencies to css properties, layout properties and/or properties of the environment (parents, etc...).

In addition, I believe we should provide a StyleMutationObserver interface to the main javascript thread, with a behavior similar to the HTML MutationObserver, and which would allow to bind events for instance for when a CustomPaint needs input information but can't get access to it directly (the script running on the main thread may update the value of css custom properties to accurately update the painting to the current state).

This would also allow to trivially implement a querySelectorLive function, which is something a lot of people would like to have. Currently, most implementation rely on polling and other tricks to achieve this effect.

tabatkins commented 9 years ago

This specification would define how things like CustomPaint, the ApplyHook and other things like CustomLayout declaratively define their dependencies to css properties, layout properties and/or properties of the environment (parents, etc...).

Why shouldn't this just be included in each spec?

In addition, I believe we should provide a StyleMutationObserver interface to the main javascript thread,

This is a completely different topic. Please fork it to a new issue.

FremyCompany commented 9 years ago

In addition, I believe we should provide a StyleMutationObserver interface to the main javascript thread, This is a completely different topic. Please fork it to a new issue.

This specification would define how things like CustomPaint, the ApplyHook and other things like CustomLayout declaratively define their dependencies to css properties, layout properties and/or properties of the environment (parents, etc...). Why shouldn't this just be included in each spec?

I agree the second part is another proposal which should get its own issue. I think the point was to show a lot of (current and future) specifications will feature some kind of dependency mechanism and (my personal belief) is that the world will be a better place if we use the same mechanism for those dependencies.

This will make it easier for librairies to expose their dependencies cleanly in a format that another library/bundler can understand, and not as something that's forcibly buried deep in the code due to incompatible API calls.

Does that make sense to you?

tabatkins commented 9 years ago

Not really. I'm not sure I understand what you're asking for, then. Can you give an example?

FremyCompany commented 9 years ago

I would like components to be able to reuse the same expression of their dependencies across the various API, which would allow to create toolchains for instance for merging, detecting conflicts or more generally dealing ideally with the dependencies of polyfills.

If each API define the dependencies in its own way, it may be harder to achieve.

I don't mean to say all dependencies must work in all context, but more that the syntax for declaring the dependencies should uniquely reference a dependency target in all contexts it can be used, and not have two different syntax for the same dependency nor two different dependencies sharing the same name.

Is that description clearer?

tabatkins commented 9 years ago

Oh, like the apply hook has inputProperties?

FremyCompany commented 9 years ago

Yep, exactly. I think we should make sure the formats used by "inputProperties" and the like are compatible with each-other (i.e. there's a clean set that works everywhere and hopefully no element that would mean something else depending on where it's used).

tabatkins commented 9 years ago

That's definitely true. I don't think we need a separate spec for it, but making sure we're consistent across the specs is definitely important.