-
Notifications
You must be signed in to change notification settings - Fork 26.2k
fix(platform-server): generate correct stylings for camel case names #22263
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
Conversation
de930c7
to
c0c5f48
Compare
"tslib": "^1.7.1", | ||
"domino": "^1.0.29", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Domino use semantic versioning? If so then this PR is also a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Domino uses "semantic versioning". The difference between v1 and v2 is an internal change in how they represent DOM nodes (they switched to a linked list implementation) and they added a fix for namespacing issues.
If we want to consider this a breaking change, I can add that to the PR description, but that just makes the timing of the PR even better with v6 in beta.
9d8635c
to
cd75881
Compare
getStyle(element: any, styleName: string): string { | ||
const styleMap = this._readStyleAttribute(element); | ||
return styleMap.hasOwnProperty(styleName) ? (styleMap as any)[styleName] : ''; | ||
return element.style[styleName] || element.style.getPropertyValue(styleName) || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the last || ''
?
https://github.com/fgnass/domino/blob/master/lib/CSSStyleDeclaration.js#L99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
(styleMap as any)[styleName] = styleValue; | ||
this._writeStyleAttribute(element, styleMap); | ||
styleName = styleName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); | ||
element.style[styleName] = styleValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok to access style[name]
directly in domino ?
seems like there is style.properties[name]
What about using setPropertyValue
instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's fine. It follows the spec for CSSStyleDeclaration
, which allows for string indexing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CaerusKaru What spec are you talking about ?
I see no mention of []
indexing in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vicb The indexing is by number, not string as I originally thought. The item
operator indicates number aliasing, like with NodeList
.
In the case of platform-server, which is using an out-of-date form of CSSStyleDeclaration, Domino does not provide us with enough cover to use setPropertyValue
and getPropertyValue
. It needs to be updated to include modern CSS style properties. This change gets around that requirement for now by just directly indexing. While not spec compliant, it's a little more palatable than just writing huge style chunks as was previous. Plus if Domino does get updated in the near future, we can just replace the one-liners with their compatible get/setPropertyValue
forms.
I agree it's not ideal, but we're a little handicapped by our server DOM implementation, which works well for just about everything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok wait, I found it! I knew I wasn't going crazy. In the CSSOM spec, found here:
partial interface CSSStyleDeclaration {
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString _camel_cased_attribute;
};
Which in JavaScript means that for all possible camel-cased attributes, you have string indexing allowed.
Seems like |
* Add correct mapping from camel case to kebab case for CSS style names * Remove internal CSS methods in favor of native Domino APIs Fixes angular#19235
@vicb As stated above, using string indexing is totally valid for |
@vicb Ok I've done a deeper dive into the issue, and here's where I've ended up. If you set a property that isn't specifically enumerated by Domino (which at this point is a little outdated re flex and grid, etc), it gets stored raw on the instance of the The solution here essentially bypasses the Domino internal implementation and instead relies on the contract for |
…ngular#22263) * Add correct mapping from camel case to kebab case for CSS style names * Remove internal CSS methods in favor of native Domino APIs Fixes angular#19235 PR Close angular#22263
Since this update, it's no longer possible to apply |
* Partially reverts angular#22263 due to lack of total spec complicance on the server * Maintains the camel-case styles fix
…ngular#22263) * Add correct mapping from camel case to kebab case for CSS style names * Remove internal CSS methods in favor of native Domino APIs Fixes angular#19235 PR Close angular#22263
* Partially reverts angular#22263 due to lack of total spec compliance on the server * Maintains the camel-case styles fix PR Close angular#22527
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
names
Fixes #19235