refactor(ViewEncapsulation): rename to PascalCase

BREAKING CHANGE

- ViewEncapsulation.EMULATED => ViewEncapsulation.Emulated
- ViewEncapsulation.NATIVE => ViewEncapsulation.Native
- ViewEncapsulation.NONE => ViewEncapsulation.None

Closes #3889
This commit is contained in:
Misko Hevery 2015-08-28 21:03:19 -07:00 committed by Miško Hevery
parent e916836261
commit c349bbbc08
30 changed files with 75 additions and 75 deletions

View File

@ -91,9 +91,9 @@ export class ViewMetadata {
/**
* Specify how the template and the styles should be encapsulated.
* The default is {@link ViewEncapsulation#EMULATED `ViewEncapsulation.EMULATED`} if the view
* The default is {@link ViewEncapsulation#Emulated `ViewEncapsulation.Emulated`} if the view
* has styles,
* otherwise {@link ViewEncapsulation#NONE `ViewEncapsulation.NONE`}.
* otherwise {@link ViewEncapsulation#None `ViewEncapsulation.None`}.
*/
encapsulation: ViewEncapsulation;

View File

@ -293,15 +293,15 @@ export enum ViewEncapsulation {
* Emulate scoping of styles by preprocessing the style rules
* and adding additional attributes to elements. This is the default.
*/
EMULATED,
Emulated,
/**
* Uses the native mechanism of the renderer. For the DOM this means creating a ShadowRoot.
*/
NATIVE,
Native,
/**
* Don't scope the template nor the styles.
*/
NONE
None
}
export class ViewDefinition {
@ -329,7 +329,7 @@ export class ViewDefinition {
this.styleAbsUrls = styleAbsUrls;
this.styles = styles;
this.directives = directives;
this.encapsulation = isPresent(encapsulation) ? encapsulation : ViewEncapsulation.EMULATED;
this.encapsulation = isPresent(encapsulation) ? encapsulation : ViewEncapsulation.Emulated;
}
}

View File

@ -57,7 +57,7 @@ export class DomCompiler extends RenderCompiler {
styles: null,
styleAbsUrls: null,
directives: [directiveMetadata],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
});
let selector = CssSelector.parse(directiveMetadata.selector)[0];
@ -75,7 +75,7 @@ export class DomCompiler extends RenderCompiler {
_compileView(viewDef: ViewDefinition, templateAndStyles: TemplateAndStyles,
protoViewType: ViewType): Promise<ProtoViewDto> {
if (viewDef.encapsulation === ViewEncapsulation.EMULATED &&
if (viewDef.encapsulation === ViewEncapsulation.Emulated &&
templateAndStyles.styles.length === 0) {
viewDef = this._normalizeViewEncapsulationIfThereAreNoStyles(viewDef);
}
@ -84,7 +84,7 @@ export class DomCompiler extends RenderCompiler {
var compiledStyles = pipeline.processStyles(templateAndStyles.styles);
var compileElements = pipeline.processElements(
this._createTemplateElm(templateAndStyles.template), protoViewType, viewDef);
if (viewDef.encapsulation === ViewEncapsulation.NATIVE) {
if (viewDef.encapsulation === ViewEncapsulation.Native) {
prependAll(DOM.content(compileElements[0].element),
compiledStyles.map(style => DOM.createStyleElement(style)));
} else {
@ -107,14 +107,14 @@ export class DomCompiler extends RenderCompiler {
}
_normalizeViewEncapsulationIfThereAreNoStyles(viewDef: ViewDefinition): ViewDefinition {
if (viewDef.encapsulation === ViewEncapsulation.EMULATED) {
if (viewDef.encapsulation === ViewEncapsulation.Emulated) {
return new ViewDefinition({
componentId: viewDef.componentId,
templateAbsUrl: viewDef.templateAbsUrl, template: viewDef.template,
styleAbsUrls: viewDef.styleAbsUrls,
styles: viewDef.styles,
directives: viewDef.directives,
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
});
} else {
return viewDef;

View File

@ -15,7 +15,7 @@ export class StyleEncapsulator implements CompileStep {
if (isElementWithTag(current.element, NG_CONTENT_ELEMENT_NAME)) {
current.inheritedProtoView.bindNgContent();
} else {
if (this._view.encapsulation === ViewEncapsulation.EMULATED) {
if (this._view.encapsulation === ViewEncapsulation.Emulated) {
this._processEmulatedScopedElement(current, parent);
}
}
@ -23,7 +23,7 @@ export class StyleEncapsulator implements CompileStep {
processStyle(style: string): string {
var encapsulation = this._view.encapsulation;
if (encapsulation === ViewEncapsulation.EMULATED) {
if (encapsulation === ViewEncapsulation.Emulated) {
return this._shimCssForComponent(style, this._view.componentId);
} else {
return style;

View File

@ -189,7 +189,7 @@ export class ElementBinderBuilder {
throw new BaseException('Only one nested view per element is allowed');
}
this.nestedProtoView =
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.NONE);
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.None);
return this.nestedProtoView;
}

View File

@ -193,7 +193,7 @@ function mergeComponent(hostProtoView: ClonedProtoView, binderIdx: number,
// unwrap the fragment elements into arrays of nodes after projecting
var fragments = extractFragmentNodesFromElements(fragmentElements);
var useNativeShadowRoot = nestedProtoView.original.encapsulation === ViewEncapsulation.NATIVE;
var useNativeShadowRoot = nestedProtoView.original.encapsulation === ViewEncapsulation.Native;
if (useNativeShadowRoot) {
targetElementsWithNativeShadowRoot.add(hostElement);
}

View File

@ -57,9 +57,9 @@ export class Serializer {
this._enumRegistry.set(ViewType, viewTypeMap);
var viewEncapsulationMap = new Map<number, any>();
viewEncapsulationMap[0] = ViewEncapsulation.EMULATED;
viewEncapsulationMap[1] = ViewEncapsulation.NATIVE;
viewEncapsulationMap[2] = ViewEncapsulation.NONE;
viewEncapsulationMap[0] = ViewEncapsulation.Emulated;
viewEncapsulationMap[1] = ViewEncapsulation.Native;
viewEncapsulationMap[2] = ViewEncapsulation.None;
this._enumRegistry.set(ViewEncapsulation, viewEncapsulationMap);
var propertyBindingTypeMap = new Map<number, any>();

View File

@ -473,7 +473,7 @@ class Simple {
@View({
template: 'SIMPLE(<content></content>)',
directives: [],
encapsulation: ViewEncapsulation.NATIVE
encapsulation: ViewEncapsulation.Native
})
class SimpleNative {
}

View File

@ -191,14 +191,14 @@ export function runCompilerCommonTests() {
});
}));
it('should store the styles in the SharedStylesHost for ViewEncapsulation.NONE',
it('should store the styles in the SharedStylesHost for ViewEncapsulation.None',
inject([AsyncTestCompleter], (async) => {
var compiler = createCompiler();
compiler.compile(new ViewDefinition({
componentId: 'someComponent',
template: '',
styles: ['a {};'],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
}))
.then((protoViewDto) => {
expect(DOM.getInnerHTML(templateRoot(protoViewDto))).toEqual('');
@ -207,14 +207,14 @@ export function runCompilerCommonTests() {
});
}));
it('should store the styles in the SharedStylesHost for ViewEncapsulation.EMULATED',
it('should store the styles in the SharedStylesHost for ViewEncapsulation.Emulated',
inject([AsyncTestCompleter], (async) => {
var compiler = createCompiler();
compiler.compile(new ViewDefinition({
componentId: 'someComponent',
template: '',
styles: ['a {};'],
encapsulation: ViewEncapsulation.EMULATED
encapsulation: ViewEncapsulation.Emulated
}))
.then((protoViewDto) => {
expect(DOM.getInnerHTML(templateRoot(protoViewDto))).toEqual('');
@ -224,14 +224,14 @@ export function runCompilerCommonTests() {
}));
if (DOM.supportsNativeShadowDOM()) {
it('should store the styles in the template for ViewEncapsulation.NATIVE',
it('should store the styles in the template for ViewEncapsulation.Native',
inject([AsyncTestCompleter], (async) => {
var compiler = createCompiler();
compiler.compile(new ViewDefinition({
componentId: 'someComponent',
template: '',
styles: ['a {};'],
encapsulation: ViewEncapsulation.NATIVE
encapsulation: ViewEncapsulation.Native
}))
.then((protoViewDto) => {
expect(DOM.getInnerHTML(templateRoot(protoViewDto)))
@ -242,24 +242,24 @@ export function runCompilerCommonTests() {
}));
}
it('should default to ViewEncapsulation.NONE if no styles are specified',
it('should default to ViewEncapsulation.None if no styles are specified',
inject([AsyncTestCompleter], (async) => {
var compiler = createCompiler();
compiler.compile(
new ViewDefinition({componentId: 'someComponent', template: '', styles: []}))
.then((protoView) => {
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.NONE);
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.None);
async.done();
});
}));
it('should default to ViewEncapsulation.EMULATED if styles are specified',
it('should default to ViewEncapsulation.Emulated if styles are specified',
inject([AsyncTestCompleter], (async) => {
var compiler = createCompiler();
compiler.compile(new ViewDefinition(
{componentId: 'someComponent', template: '', styles: ['a {};']}))
.then((protoView) => {
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.EMULATED);
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.Emulated);
async.done();
});
}));

View File

@ -53,7 +53,7 @@ export function main() {
new MockStep((parent, current, control) => {
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
current.inheritedProtoView =
new ProtoViewBuilder(current.element, ViewType.EMBEDDED, ViewEncapsulation.NONE);
new ProtoViewBuilder(current.element, ViewType.EMBEDDED, ViewEncapsulation.None);
}
})
]);

View File

@ -62,38 +62,38 @@ export function main() {
return compileElements[0].inheritedProtoView;
}
describe('ViewEncapsulation.NONE', () => {
describe('ViewEncapsulation.None', () => {
it('should not change the styles', () => {
var cs = processStyles(ViewEncapsulation.NONE, 'someComponent', ['.one {}']);
var cs = processStyles(ViewEncapsulation.None, 'someComponent', ['.one {}']);
expect(cs[0]).toEqual('.one {}');
});
});
describe('ViewEncapsulation.NATIVE', () => {
describe('ViewEncapsulation.Native', () => {
it('should not change the styles', () => {
var cs = processStyles(ViewEncapsulation.NATIVE, 'someComponent', ['.one {}']);
var cs = processStyles(ViewEncapsulation.Native, 'someComponent', ['.one {}']);
expect(cs[0]).toEqual('.one {}');
});
});
describe('ViewEncapsulation.EMULATED', () => {
describe('ViewEncapsulation.Emulated', () => {
it('should scope styles', () => {
var cs = processStyles(ViewEncapsulation.EMULATED, 'someComponent', ['.foo {} :host {}']);
var cs = processStyles(ViewEncapsulation.Emulated, 'someComponent', ['.foo {} :host {}']);
expect(cs[0]).toEqual(".foo[_ngcontent-someapp-0] {\n\n}\n\n[_nghost-someapp-0] {\n\n}");
});
it('should return the same style given the same component', () => {
var style = '.foo {} :host {}';
var cs1 = processStyles(ViewEncapsulation.EMULATED, 'someComponent', [style]);
var cs2 = processStyles(ViewEncapsulation.EMULATED, 'someComponent', [style]);
var cs1 = processStyles(ViewEncapsulation.Emulated, 'someComponent', [style]);
var cs2 = processStyles(ViewEncapsulation.Emulated, 'someComponent', [style]);
expect(cs1[0]).toEqual(cs2[0]);
});
it('should return different styles given different components', () => {
var style = '.foo {} :host {}';
var cs1 = processStyles(ViewEncapsulation.EMULATED, 'someComponent1', [style]);
var cs2 = processStyles(ViewEncapsulation.EMULATED, 'someComponent2', [style]);
var cs1 = processStyles(ViewEncapsulation.Emulated, 'someComponent1', [style]);
var cs2 = processStyles(ViewEncapsulation.Emulated, 'someComponent2', [style]);
expect(cs1[0]).not.toEqual(cs2[0]);
});
@ -101,13 +101,13 @@ export function main() {
it('should add a host attribute to component proto views', () => {
var template = DOM.createTemplate('<div></div>');
var protoViewBuilder =
processElements(ViewEncapsulation.EMULATED, 'someComponent', template);
processElements(ViewEncapsulation.Emulated, 'someComponent', template);
expect(protoViewBuilder.hostAttributes.get('_nghost-someapp-0')).toEqual('');
});
it('should not add a host attribute to embedded proto views', () => {
var template = DOM.createTemplate('<div></div>');
var protoViewBuilder = processElements(ViewEncapsulation.EMULATED, 'someComponent',
var protoViewBuilder = processElements(ViewEncapsulation.Emulated, 'someComponent',
template, ViewType.EMBEDDED);
expect(protoViewBuilder.hostAttributes.size).toBe(0);
});
@ -115,19 +115,19 @@ export function main() {
it('should not add a host attribute to host proto views', () => {
var template = DOM.createTemplate('<div></div>');
var protoViewBuilder =
processElements(ViewEncapsulation.EMULATED, 'someComponent', template, ViewType.HOST);
processElements(ViewEncapsulation.Emulated, 'someComponent', template, ViewType.HOST);
expect(protoViewBuilder.hostAttributes.size).toBe(0);
});
it('should add an attribute to the content elements', () => {
var template = DOM.createTemplate('<div></div>');
processElements(ViewEncapsulation.EMULATED, 'someComponent', template);
processElements(ViewEncapsulation.Emulated, 'someComponent', template);
expect(DOM.getInnerHTML(template)).toEqual('<div _ngcontent-someapp-0=""></div>');
});
it('should not add an attribute to the content elements for host views', () => {
var template = DOM.createTemplate('<div></div>');
processElements(ViewEncapsulation.EMULATED, 'someComponent', template, ViewType.HOST);
processElements(ViewEncapsulation.Emulated, 'someComponent', template, ViewType.HOST);
expect(DOM.getInnerHTML(template)).toEqual('<div></div>');
});
});

View File

@ -215,7 +215,7 @@ export function main() {
componentId: 'someComponent',
template: 'hello',
directives: [],
encapsulation: ViewEncapsulation.NATIVE
encapsulation: ViewEncapsulation.Native
})
])
.then((protoViewMergeMappings) => {
@ -234,7 +234,7 @@ export function main() {
componentId: 'someComponent',
template: '',
directives: [],
encapsulation: ViewEncapsulation.NATIVE,
encapsulation: ViewEncapsulation.Native,
styles: ['a {};']
})
])
@ -244,7 +244,7 @@ export function main() {
componentId: 'someComponent',
template: '',
directives: [],
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
styles: ['b {};']
}))
.then(_ => {
@ -254,7 +254,7 @@ export function main() {
componentId: 'someComponent',
template: '',
directives: [],
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
styles: ['c {};']
}))
.then(_ => {

View File

@ -29,7 +29,7 @@ export function main() {
beforeEach(() => {
templateCloner = new TemplateCloner(-1);
builder =
new ProtoViewBuilder(DOM.createTemplate(''), ViewType.EMBEDDED, ViewEncapsulation.NONE);
new ProtoViewBuilder(DOM.createTemplate(''), ViewType.EMBEDDED, ViewEncapsulation.None);
});
if (!IS_DART) {

View File

@ -264,7 +264,7 @@ export function main() {
tb.compiler.compileHost(rootDirective('root'))
.then((rootProtoViewDto) => {
var builder = new ProtoViewBuilder(DOM.createTemplate(''), ViewType.COMPONENT,
ViewEncapsulation.NONE);
ViewEncapsulation.None);
builder.setHostAttribute('a', 'b');
var componentProtoViewDto = builder.build(new ElementSchemaRegistry(), cloner);
tb.merge([rootProtoViewDto, componentProtoViewDto])
@ -294,8 +294,8 @@ function runAndAssert(hostElementName: string, componentTemplates: string[],
cloner: TemplateCloner) => {
tb.compileAndMerge(rootComp, componentTemplates.map(template => componentView(
template, useNativeEncapsulation ?
ViewEncapsulation.NATIVE :
ViewEncapsulation.NONE)))
ViewEncapsulation.Native :
ViewEncapsulation.None)))
.then((mergeMappings) => {
expect(stringify(cloner, mergeMappings)).toEqual(expectedFragments);
async.done();
@ -309,7 +309,7 @@ function rootDirective(hostElementName: string) {
}
function componentView(template: string,
encapsulation: ViewEncapsulation = ViewEncapsulation.NONE) {
encapsulation: ViewEncapsulation = ViewEncapsulation.None) {
return new ViewDefinition({
componentId: 'someComp',
template: template,

View File

@ -17,7 +17,7 @@ import {isPresent} from 'angular2/src/core/facade/lang';
})
@View({
templateUrl: 'package:angular2_material/src/components/button/button.html',
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
})
export class MdButton {
/** Whether a mousedown has occured on this element in the last 100ms. */
@ -61,7 +61,7 @@ export class MdButton {
})
@View({
templateUrl: 'package:angular2_material/src/components/button/button.html',
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdAnchor extends MdButton {
tabIndex: number;

View File

@ -18,7 +18,7 @@ import {NumberWrapper} from 'angular2/src/core/facade/lang';
@View({
templateUrl: 'package:angular2_material/src/components/checkbox/checkbox.html',
directives: [],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdCheckbox {
/** Whether this checkbox is checked. */

View File

@ -210,7 +210,7 @@ export class MdDialogConfig {
},
})
@View({
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
templateUrl: 'package:angular2_material/src/components/dialog/dialog.html',
directives: [forwardRef(() => MdDialogContent)]
})
@ -258,7 +258,7 @@ class MdDialogContent {
'(click)': 'onClick()',
},
})
@View({template: '', encapsulation: ViewEncapsulation.NONE})
@View({template: '', encapsulation: ViewEncapsulation.None})
class MdBackdrop {
dialogRef: MdDialogRef;

View File

@ -32,7 +32,7 @@ class RowHeightMode {
})
@View({
templateUrl: 'package:angular2_material/src/components/grid_list/grid_list.html',
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdGridList {
/** Array of tiles that are being rendered. */
@ -230,7 +230,7 @@ export class MdGridList {
})
@View({
templateUrl: 'package:angular2_material/src/components/grid_list/grid_tile.html',
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdGridTile {
gridList: MdGridList;

View File

@ -3,7 +3,7 @@ import {Component, View, ViewEncapsulation} from 'angular2/angular2';
@Component({selector: 'md-progress-circular'})
@View({
templateUrl: 'package:angular2_material/src/components/progress-circular/progress_circular.html',
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdProgressCircular {
constructor() {}

View File

@ -27,7 +27,7 @@ class ProgressMode {
@View({
templateUrl: 'package:angular2_material/src/components/progress-linear/progress_linear.html',
directives: [],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdProgressLinear {
/** Value for the primary bar. */

View File

@ -47,7 +47,7 @@ var _uniqueIdCounter: number = 0;
})
@View({
templateUrl: 'package:angular2_material/src/components/radio/radio_group.html',
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdRadioGroup {
/** The selected value for the radio group. The value comes from the options. */
@ -205,7 +205,7 @@ export class MdRadioGroup {
@View({
templateUrl: 'package:angular2_material/src/components/radio/radio_button.html',
directives: [],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdRadioButton {
/** Whether this radio is checked. */

View File

@ -17,7 +17,7 @@ import {MdCheckbox} from "../checkbox/checkbox";
@View({
templateUrl: 'package:angular2_material/src/components/switcher/switch.html',
directives: [],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
export class MdSwitch extends MdCheckbox {
constructor(@Attribute('tabindex') tabindex: string) {

View File

@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
@View({
templateUrl: './demo_app.html',
directives: [MdButton, MdAnchor, NgFor],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
class DemoApp {
previousClick: string;

View File

@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
@View({
templateUrl: './demo_app.html',
directives: [MdCheckbox],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
class DemoApp {
toggleCount: number;

View File

@ -24,7 +24,7 @@ import {isPresent} from 'angular2/src/core/facade/lang';
@View({
templateUrl: './demo_app.html',
directives: [],
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
})
class DemoApp {
dialog: MdDialog;
@ -70,7 +70,7 @@ class DemoApp {
properties: ['numCoconuts'],
})
@View({
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
template: `
<h2>This is the dialog content</h2>
<p>There are {{numCoconuts}} coconuts.</p>

View File

@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
@View({
templateUrl: './demo_app.html',
directives: [MdGridList, MdGridTile],
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
})
class DemoApp {
tile3RowSpan: number;

View File

@ -8,7 +8,7 @@ import {bind} from 'angular2/di';
@View({
templateUrl: './demo_app.html',
directives: [MdInputContainer, MdInput],
encapsulation: ViewEncapsulation.NONE
encapsulation: ViewEncapsulation.None
})
class DemoApp {
constructor() {}

View File

@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
@View({
templateUrl: './demo_app.html',
directives: [MdProgressLinear],
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
})
class DemoApp {
progress: number;

View File

@ -12,7 +12,7 @@ import {bind} from 'angular2/di';
@View({
templateUrl: './demo_app.html',
directives: [MdRadioGroup, MdRadioButton],
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
})
class DemoApp {
thirdValue;

View File

@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
@View({
templateUrl: './demo_app.html',
directives: [MdSwitch],
encapsulation: ViewEncapsulation.NONE,
encapsulation: ViewEncapsulation.None,
})
class DemoApp {
toggleCount: number;