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

Commit

Permalink
- fixes host styles for type extension elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Oct 26, 2013
1 parent bcf1dc3 commit 157fca1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ShadowCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ var ShadowCSS = {
return self.scopeHostCss(p1, name, typeExtension);
});
cssText = rulesToCss(this.findAtHostRules(cssToRules(cssText),
new RegExp('^' + name + selectorReSuffix, 'm')));
this.makeScopeMatcher(name, typeExtension)));
return cssText;
},
scopeHostCss: function(cssText, name, typeExtension) {
Expand Down Expand Up @@ -444,10 +444,13 @@ var ShadowCSS = {
return r.join(', ');
},
selectorNeedsScoping: function(selector, name, typeExtension) {
var matchScope = typeExtension ? name : '\\[is=' + name + '\\]';
var re = new RegExp('^(' + matchScope + ')' + selectorReSuffix, 'm');
var re = this.makeScopeMatcher(name, typeExtension);
return !selector.match(re);
},
makeScopeMatcher: function(name, typeExtension) {
var matchScope = typeExtension ? '\\[is=[\'"]?' + name + '[\'"]?\\]' : name;
return new RegExp('^(' + matchScope + ')' + selectorReSuffix, 'm');
},
// scope via name and [is=name]
applySimpleSelectorScope: function(selector, name, typeExtension) {
var scoper = typeExtension ? '[is=' + name + ']' : name;
Expand Down
6 changes: 6 additions & 0 deletions test/html/styling/host.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ <h4>Expected: 20px padding</h4>
chai.assert.equal(zimStyle2.paddingLeft, '20px',
'@host styles are loaded via external sheet in import (paddingLeft)');

var xButton = document.querySelector('[is=x-button]');
var xButtonStyle = getComputedStyle(xButton);
chai.assert.equal(xButtonStyle.backgroundColor, 'rgb(0, 128, 0)',
'@host styles function for type extension (backgroundColor)');


done();


Expand Down

0 comments on commit 157fca1

Please sign in to comment.