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

@ -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,