Update: The first two issues, *= and ~=, are no longer a problem (last tested in RC.4) but the problem with spaces in values still exists. See the third comment.
Emulated view encapsulation can fail if there are any attribute selectors using contains or contains word, so *= or ~=.
Example:
Let's say we have a component with the selector my-component. It also has a custom attriute called custom-attribute. First a working case, using attribute equals.
my-component[custom-attribute="value"] {
background-color: red;
}
# View encapsulation converts this to
my-component[custom-attribute="value"][_ngcontent-eod-X] {
background-color: red;
}
In this case both the view encaptulation and the custom attribute selector will work as expected. However, lets use a contains selector instead (note the *= in the selector).
my-component[custom-attribute*="value"] {
background-color: red;
}
This time the view encapsulation gets confused and adds the new attribute in the middle of the selector!
my-component[custom-attribute[_ngcontent-eod-X]*="value"] {
background-color: red;
}
Needless to say this cases both the encaptulation and the attribute selector to fail.
Final note: It appears that the ^= doesn't have this problem.
Update: The first two issues,
*=and~=, are no longer a problem (last tested in RC.4) but the problem with spaces in values still exists. See the third comment.Emulated view encapsulation can fail if there are any attribute selectors using contains or contains word, so
*=or~=.Example:
Let's say we have a component with the selector
my-component. It also has a custom attriute calledcustom-attribute. First a working case, using attribute equals.In this case both the view encaptulation and the custom attribute selector will work as expected. However, lets use a contains selector instead (note the
*=in the selector).This time the view encapsulation gets confused and adds the new attribute in the middle of the selector!
Needless to say this cases both the encaptulation and the attribute selector to fail.
Final note: It appears that the
^=doesn't have this problem.