Skip to content

[css-typed-om-1] How does StylePropertyMap interact with CSSStyleDeclaration? #670

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

Open
bzbarsky opened this issue Feb 15, 2018 · 5 comments

Comments

@bzbarsky
Copy link

The example in https://drafts.css-houdini.org/css-typed-om-1/#numeric-objects has:

myElement.attributeStyleMap.set("z-index", CSS.number(15.4));

After that, what does myElement.style.zIndex return? Is it 15? Something else?

This doesn't actually seem to be defined anywhere. In fact, it's not even defined that mutations to the .attributeStyleMap get reflected in .style and similar for the CSSStyleRule case.

@darrnshn
Copy link
Collaborator

If the .set call was valid, then the intention is that the "liveness" of the style map would cause .style to update.

In this case, I believe this would actually be invalid and throw an error. AFAIK z-index takes an <integer> and we currently don't have an algorithm for matching against an <integer> (maybe we should? @tabatkins).

@tabatkins
Copy link
Member

We don't throw for numbers outside the supported range, so I don't know why we'd throw for non-integers on things that want an integer. We should round.

@darrnshn
Copy link
Collaborator

My interpretation is that z-index's grammar takes an <integer>, so we would fail at the grammar matching stage of StylePropertyMap.set (since nothing matches <integer> atm).

For numbers outside the supported range (e.g. width), we would match successfully against the grammar <length>, but technically it's invalid because the spec text for width says it's invalid (but not in the grammar?)

Not sure if my understanding is correct, but we should probably have a consistent behaviour for both cases.

@tabatkins
Copy link
Member

Oh, hm, that's a good question. I suppose that CSS Syntax handwaves what it means to match the grammar, too; it's not clear whether range restrictions are included in that (but usually they should be, I think).

@darrnshn
Copy link
Collaborator

Yeah CSS handwaves it bit :/ Let's just go with #647 and just calcify both, to be consistent?

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

3 participants