diff --git a/lib/core/directive.dart b/lib/core/directive.dart index 4e1175995..e336567bc 100644 --- a/lib/core/directive.dart +++ b/lib/core/directive.dart @@ -178,6 +178,9 @@ abstract class NgAnnotation { } +bool _applyAuthorStylesDeprecationWarningPrinted = false; +bool _resetStyleInheritanceDeprecationWarningPrinted = false; + /** * Meta-data marker placed on a class which should act as a controller for the * component. Angular components are a light-weight version of web-components. @@ -214,14 +217,34 @@ class NgComponent extends NgAnnotation { /** * Set the shadow root applyAuthorStyles property. See shadow-DOM * documentation for further details. + * + * This feature will be removed in Chrome 35. */ - final bool applyAuthorStyles; + @deprecated + bool get applyAuthorStyles { + if (!_applyAuthorStylesDeprecationWarningPrinted && _applyAuthorStyles == true) { + print("WARNING applyAuthorStyles is deprecated in component $selector"); + _applyAuthorStylesDeprecationWarningPrinted = true; + } + return _applyAuthorStyles; + } + final bool _applyAuthorStyles; /** * Set the shadow root resetStyleInheritance property. See shadow-DOM * documentation for further details. + * + * This feature will be removed in Chrome 35. */ - final bool resetStyleInheritance; + @deprecated + bool get resetStyleInheritance { + if (!_resetStyleInheritanceDeprecationWarningPrinted && _resetStyleInheritance == true) { + print("WARNING resetStyleInheritance is deprecated in component $selector"); + _resetStyleInheritanceDeprecationWarningPrinted = true; + } + return _resetStyleInheritance; + } + final bool _resetStyleInheritance; /** * An expression under which the component's controller instance will be @@ -234,8 +257,8 @@ class NgComponent extends NgAnnotation { this.template, this.templateUrl, cssUrl, - this.applyAuthorStyles, - this.resetStyleInheritance, + applyAuthorStyles, + resetStyleInheritance, this.publishAs, module, map, @@ -244,6 +267,8 @@ class NgComponent extends NgAnnotation { exportExpressions, exportExpressionAttrs}) : _cssUrls = cssUrl, + _applyAuthorStyles = applyAuthorStyles, + _resetStyleInheritance = resetStyleInheritance, super(selector: selector, children: NgAnnotation.COMPILE_CHILDREN, visibility: visibility, diff --git a/test/core/core_directive_spec.dart b/test/core/core_directive_spec.dart index 2e6168468..9f8159280 100644 --- a/test/core/core_directive_spec.dart +++ b/test/core/core_directive_spec.dart @@ -23,8 +23,6 @@ void main() { expect(annotation.template).toEqual('template'); expect(annotation.templateUrl).toEqual('templateUrl'); expect(annotation.cssUrls).toEqual(['cssUrls']); - expect(annotation.applyAuthorStyles).toEqual(true); - expect(annotation.resetStyleInheritance).toEqual(true); expect(annotation.publishAs).toEqual('ctrl'); expect(annotation.map).toEqual({ 'foo': '=>foo', @@ -83,8 +81,6 @@ class NullParser implements Parser { template: 'template', templateUrl: 'templateUrl', cssUrl: const ['cssUrls'], - applyAuthorStyles: true, - resetStyleInheritance: true, publishAs: 'ctrl', module: AnnotatedIoComponent.module, visibility: NgDirective.LOCAL_VISIBILITY, diff --git a/test/core_dom/shadow_root_options_spec.dart b/test/core_dom/shadow_root_options_spec.dart deleted file mode 100644 index 0a8770c38..000000000 --- a/test/core_dom/shadow_root_options_spec.dart +++ /dev/null @@ -1,88 +0,0 @@ -library shadow_root_options_spec; - -import '../_specs.dart'; - -@NgComponent( - selector: 'reset-style-inheritance', - template: '
Reset me foo
', - applyAuthorStyles: false, - resetStyleInheritance: true -) -class ResetStyleInheritanceComponent { - static var lastTemplateLoader; - ResetStyleInheritanceComponent(Element elt, TemplateLoader tl) { - lastTemplateLoader = tl.template; - } -} - -@NgComponent( - selector: 'apply-author-style', - template: '
Style me foo
', - applyAuthorStyles: true -) -class ApplyAuthorStyleComponent { - static var lastTemplateLoader; - ApplyAuthorStyleComponent(Element elt, TemplateLoader tl) { - lastTemplateLoader = tl.template; - } -} - -@NgComponent( - selector: 'default-options', - template: '
Style me foo
' -) -class DefaultOptionsComponent { - static var lastTemplateLoader; - DefaultOptionsComponent(Element elt, TemplateLoader tl) { - lastTemplateLoader = tl.template; - } -} - -main() { - describe('shadow dom options', () { - Compiler $compile; - DirectiveMap directives; - Injector injector; - Scope $rootScope; - - beforeEachModule((Module module) { - module - ..type(ApplyAuthorStyleComponent) - ..type(ResetStyleInheritanceComponent) - ..type(DefaultOptionsComponent); - return (Injector _injector) { - injector = _injector; - $compile = injector.get(Compiler); - $rootScope = injector.get(Scope); - directives = injector.get(DirectiveMap); - }; - }); - - it('should respect the apply-author-style option', async(() { - var element = $( - '' + - 'not included' + - 'not included'); - element.forEach((elt) { document.body.append(elt); }); // we need the computed style. - $compile(element, directives)(injector, element); - - microLeap(); - expect(element[1].shadowRoot.query('div').getComputedStyle().border).toContain('3px solid'); - // ""0px none"" is the default style. - expect(element[2].shadowRoot.query('div').getComputedStyle().border).toContain('0px none'); - })); - - it('should respect the reset-style-inheritance option', async(() { - var element = $( - '' + // font-size inherit's by default - 'not included' + - 'not included'); - element.forEach((elt) { document.body.append(elt); }); // we need the computed style. - $compile(element, directives)(injector, element); - - microLeap(); - expect(element[1].shadowRoot.query('div').getComputedStyle().fontSize).toEqual('16px'); - expect(element[2].shadowRoot.query('div').getComputedStyle().fontSize).toEqual('20px'); - })); - }); -}