Style binding doesn't account for -webkit prefixes #54878
Labels
area: core
Issues related to the framework runtime
core: stylesheets
feature
Issue that requests a new feature
Milestone
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
I've noticed that Angular's style binding doesn't seem to populate the comparable -webkit features in the way I expected. For example, I had the following line:
<div [style.mask-image]="'url(' + button.iconURL + ')'"></div>
This works fine and applies the mask correctly in some cases, but on browsers which would use
-webkit-mask-image
instead ofmask-image
, the field is instead left unpopulated. I tried to get around this by adding[style.webkit-mask-image]="'url(' + button.iconURL + ')'"
, but as far as I can tell it doesn't exist.I ultimately had to get around this by using the following:
<div style="mask-image: url('{{ button.iconURL }}'); -webkit-mask-image: url('{{ button.iconURL }}');"></div>
While this works in an instance like this one, where the line is inside an
*ngFor
, this quickly seems to become more unwieldly when the used variable is dictated by something like a Boolean. For example, this:<div [style.mask-image]="ribbonPinned ? 'url(../../../../assets/ui-element-unpin.svg)' : 'url(../../../../assets/ui-element-pin.svg)'"></div>
Becomes:
<div style="{{ ribbonPinned ? 'mask-image: url(../../../../assets/ui-element-unpin.svg); -webkit-mask-image: url(../../../../assets/ui-element-unpin.svg);' : 'mask-image: url(../../../../assets/ui-element-pin.svg); -webkit-mask-image: url(../../../../assets/ui-element-pin.svg);' }}"></div>
This does provide the functionality I need but feels like a huge pain in the arse for something which should be relatively simple. VS Code also flags it as an empty ruleset which makes it feel worse.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: