Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 157fca1

Browse files
committed
- fixes host styles for type extension elements.
1 parent bcf1dc3 commit 157fca1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/ShadowCSS.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ var ShadowCSS = {
322322
return self.scopeHostCss(p1, name, typeExtension);
323323
});
324324
cssText = rulesToCss(this.findAtHostRules(cssToRules(cssText),
325-
new RegExp('^' + name + selectorReSuffix, 'm')));
325+
this.makeScopeMatcher(name, typeExtension)));
326326
return cssText;
327327
},
328328
scopeHostCss: function(cssText, name, typeExtension) {
@@ -444,10 +444,13 @@ var ShadowCSS = {
444444
return r.join(', ');
445445
},
446446
selectorNeedsScoping: function(selector, name, typeExtension) {
447-
var matchScope = typeExtension ? name : '\\[is=' + name + '\\]';
448-
var re = new RegExp('^(' + matchScope + ')' + selectorReSuffix, 'm');
447+
var re = this.makeScopeMatcher(name, typeExtension);
449448
return !selector.match(re);
450449
},
450+
makeScopeMatcher: function(name, typeExtension) {
451+
var matchScope = typeExtension ? '\\[is=[\'"]?' + name + '[\'"]?\\]' : name;
452+
return new RegExp('^(' + matchScope + ')' + selectorReSuffix, 'm');
453+
},
451454
// scope via name and [is=name]
452455
applySimpleSelectorScope: function(selector, name, typeExtension) {
453456
var scoper = typeExtension ? '[is=' + name + ']' : name;

test/html/styling/host.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ <h4>Expected: 20px padding</h4>
215215
chai.assert.equal(zimStyle2.paddingLeft, '20px',
216216
'@host styles are loaded via external sheet in import (paddingLeft)');
217217

218+
var xButton = document.querySelector('[is=x-button]');
219+
var xButtonStyle = getComputedStyle(xButton);
220+
chai.assert.equal(xButtonStyle.backgroundColor, 'rgb(0, 128, 0)',
221+
'@host styles function for type extension (backgroundColor)');
222+
223+
218224
done();
219225

220226

0 commit comments

Comments
 (0)