From cb84cbf54515c6f11d124df20a69900e37c16b45 Mon Sep 17 00:00:00 2001 From: alexcastillo Date: Sun, 17 Apr 2016 21:18:11 -0400 Subject: [PATCH] feat(shadow_css): add encapsulation support for CSS @supports at-rule Closes #7944 --- modules/@angular/compiler/src/shadow_css.ts | 2 +- modules/@angular/compiler/test/shadow_css_spec.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/@angular/compiler/src/shadow_css.ts b/modules/@angular/compiler/src/shadow_css.ts index e8fdcc5ab2..e93a10b05d 100644 --- a/modules/@angular/compiler/src/shadow_css.ts +++ b/modules/@angular/compiler/src/shadow_css.ts @@ -332,7 +332,7 @@ export class ShadowCss { if (rule.selector[0] != '@' || rule.selector.startsWith('@page')) { selector = this._scopeSelector(rule.selector, scopeSelector, hostSelector, this.strictStyling); - } else if (rule.selector.startsWith('@media')) { + } else if (rule.selector.startsWith('@media') || rule.selector.startsWith('@supports')) { content = this._scopeSelectors(rule.content, scopeSelector, hostSelector); } return new CssRule(selector, content); diff --git a/modules/@angular/compiler/test/shadow_css_spec.ts b/modules/@angular/compiler/test/shadow_css_spec.ts index d8dd3f95fc..ee07bf40ea 100644 --- a/modules/@angular/compiler/test/shadow_css_spec.ts +++ b/modules/@angular/compiler/test/shadow_css_spec.ts @@ -60,6 +60,12 @@ export function main() { expect(s(css, 'a')).toEqual(expected); }); + it('should handle support rules', () => { + var css = '@supports (display: flex) {section {display: flex;}}'; + var expected = '@supports (display:flex) {section[a] {display:flex;}}'; + expect(s(css, 'a')).toEqual(expected); + }); + // Check that the browser supports unprefixed CSS animation it('should handle keyframes rules', () => { var css = '@keyframes foo {0% {transform:translate(-50%) scaleX(0);}}';