Your first case...
.icon-extended:before:extend(.icon-caret-n:before) {}
...you are extending something that has a class itself named .icon-extended
so that class also matches the selectors [class^="icon-"]
, [class*=" icon-"]
, thus why it works (it has nothing to do with the :extend
in this case).
Your second case...
ul.checked li:before:extend(.icon-ok:before) {color: #4fa33b;}
...you are extending something that does not have the a icon-
value noted in its selector ul.checked li
, and so would not and should not match either [class^="icon-"]
, [class*=" icon-"]
. Now your extension does not change the class name, but rather just adds the selector to the code block defining .icon-ok:before
(and only that code block). The LESS extension is looking purely at the selector string .icon-ok:before
and is not "intelligent" in knowing that such a selector would match the other selector strings [class^="icon-"]
, [class*=" icon-"]
(this is essentially what seven-phases-max's comment was about). So you have to do it explicitly, probably best like so:
ul.checked li:before:extend(
.icon-ok:before,
[class^="icon-"]:before,
[class*=" icon-"]:before) {
color: #4fa33b;
}