Comments (1)
Hi Shane, I thought more about this exact topic in the past few weeks but didn't want to start the discussion, but now we're talking about it anyway, I would like to share with you my own thoughts, and I'm interested by your honest opinion on it.
Firstly, I like this new proposal much more already than the current one. My initial plan was not to allow such conflict to happen at all, though.
I know we discussed how hard it was to define an actually useful ordering for layout librairies during last meeting and why it would be impossible to rely on registration order. I still share your opinion on these matters. My take has always been, however, that some declarative ordering was achievable, and this is where we could not agree with each other, if I remember correctly. My proposal back then didn't seem flexible enough to you and you believed it was pushing unrealistic constraints on the users of layout librairies. I took that feedback in consideration and would like to come to you with another proposal.
The idea would be to rely on a set of css properties to define the ordering of the ApplyHooks. Here's an example:
* {
priority-of-bootstrap: 1000;
priority-of-bootstrap-aspect-ratio: bootstrap 50;
priority-of-bootstrap-height: bootstrap 60;
}
Now, let's imagine a css framework called "bootstrap" has two prollyfilled properties "--bootstrap-aspect-ratio" and "--bootstrap-width" running the ApplyHooks named "bootstrap-aspect-ratio" and "bootstrap-height" respectively, and possibly both outputting the "height" property, their execution order would be define on any element of the page as COMPUTED => BOOTSTRAP-HEIGHT => BOOTSTRAP-ASPECT-RATIO => POST-COMPUTED
because (1000, 50, 0, 0, ...) < (1000, 60, 0, 0, ...)
Then, if you somehow need to inverse this ordering for an element, the fix is as simple as:
.special-case {
priority-of-bootstrap-height: bootstrap 40;
}
Now, for this element, the ordering will be inverted, as (1000, 40) < (1000, 50)
.
The point of using tuples of numbers is that you can subdivide a framework at will whenever required, and tie the ordering of logically-grouped properties coherent by putting them under the same umbrella:
* { priority-of-bootstrap-aspect-ratio: bootstrap bootstrap-core 20 }
This is useful to reorder frameworks as a whole, for instance:
* { priority-of-bootstrap: 999; priority-of-layifram: 1001; }
Even more interesting, an apply hook could potentially be allowed to modify the ordering of the apply hooks that are still pending by writing the "priority-of-..." properties. When they do so, this only affects the ordering of apply hooks which have not run already, of course, but this could be useful if a framework/property-umbrella requires an automatic but dynamic ordering of its properties. Another option would be to make priority-properties read-only or just ignore any such update during the apply-hook phase.
Another neat thing is that, the author of the page remains in total control of the ordering because he can certainly write new css rules which will override the default ordering if required, or insert a custom apply hook anywhere required in a toolchain simply by doing priority-of-my-thing: bootstrap-aspect-ratio -1
since (1000, 60, -1, 0, ...) < (1000, 60, 0, 0, ...)
.
My proposal to break ties (when priority-vectors are equals) would be to use alphabetical order of the apply-hook name. This is predictable, at least, though authors should of course rely on the priority vectors instead whenever possible.
So, what do you think of this proposal? Do you think it would make you reconsider your opinion that declarative ordering could not be made to work, or do you think this proposal is a good base to achieve some form of agreement?
from css-houdini-drafts.
Related Issues (20)
- [css-typed-om] "Add two types" algorithm seems overly complicated? HOT 2
- [css-properties-values-api] Rule validity doesn't match implementations HOT 9
- [css-properties-values-api] JS API should use CSSOMString
- [css-typed-om] structuredClone for typed-om objects
- [css-properties-values-api] Add <string> as a supported syntax name HOT 3
- [css-properties-values-api] Clarify whether lengths using viewport units are "computationally independent"
- [css-typed-om] Add missing font units to CSSNumericFactory HOT 1
- [css-properties-values-api] Providing a way for @property to be opinionated about its usage
- [css-properties-values-api] Make `initial-value` descriptor optional
- [css-properties-values-api] `<transform-function>` interpolation between different function types
- [css-properties-values-api] Clarify parsing of duplicate descriptor declarations
- [css-properties-values-api-1] Multiple custom `@property` with the same name
- [css-properties-values-api-1] `CSSPropertyRule.initialValue` should not be nullable HOT 1
- [css-typed-om-1] Combining a number and the division of two dimensions of the same type HOT 2
- [scroll-customization-api] is there still interest/ongoing discussions for scroll customization? HOT 5
- [css-properties-values-api] `initial-value` for `*` with arbitrary substitution values HOT 1
- [css-typed-om-1] Broken references in CSS Typed OM Level 1 HOT 1
- [css-animation-worklet-1] how to enable CSS.animationWorklet
- [css-typed-om-1] Republish WD HOT 4
- [css-typed-om-1] `currentColor` is not the only non-absolute color HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-houdini-drafts.