Skip to content

Commit c349bbb

Browse files
committed
refactor(ViewEncapsulation): rename to PascalCase
BREAKING CHANGE - ViewEncapsulation.EMULATED => ViewEncapsulation.Emulated - ViewEncapsulation.NATIVE => ViewEncapsulation.Native - ViewEncapsulation.NONE => ViewEncapsulation.None Closes angular#3889
1 parent e916836 commit c349bbb

File tree

30 files changed

+75
-75
lines changed

30 files changed

+75
-75
lines changed

modules/angular2/src/core/metadata/view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ export class ViewMetadata {
9191

9292
/**
9393
* Specify how the template and the styles should be encapsulated.
94-
* The default is {@link ViewEncapsulation#EMULATED `ViewEncapsulation.EMULATED`} if the view
94+
* The default is {@link ViewEncapsulation#Emulated `ViewEncapsulation.Emulated`} if the view
9595
* has styles,
96-
* otherwise {@link ViewEncapsulation#NONE `ViewEncapsulation.NONE`}.
96+
* otherwise {@link ViewEncapsulation#None `ViewEncapsulation.None`}.
9797
*/
9898
encapsulation: ViewEncapsulation;
9999

modules/angular2/src/core/render/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ export enum ViewEncapsulation {
293293
* Emulate scoping of styles by preprocessing the style rules
294294
* and adding additional attributes to elements. This is the default.
295295
*/
296-
EMULATED,
296+
Emulated,
297297
/**
298298
* Uses the native mechanism of the renderer. For the DOM this means creating a ShadowRoot.
299299
*/
300-
NATIVE,
300+
Native,
301301
/**
302302
* Don't scope the template nor the styles.
303303
*/
304-
NONE
304+
None
305305
}
306306

307307
export class ViewDefinition {
@@ -329,7 +329,7 @@ export class ViewDefinition {
329329
this.styleAbsUrls = styleAbsUrls;
330330
this.styles = styles;
331331
this.directives = directives;
332-
this.encapsulation = isPresent(encapsulation) ? encapsulation : ViewEncapsulation.EMULATED;
332+
this.encapsulation = isPresent(encapsulation) ? encapsulation : ViewEncapsulation.Emulated;
333333
}
334334
}
335335

modules/angular2/src/core/render/dom/compiler/compiler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class DomCompiler extends RenderCompiler {
5757
styles: null,
5858
styleAbsUrls: null,
5959
directives: [directiveMetadata],
60-
encapsulation: ViewEncapsulation.NONE
60+
encapsulation: ViewEncapsulation.None
6161
});
6262

6363
let selector = CssSelector.parse(directiveMetadata.selector)[0];
@@ -75,7 +75,7 @@ export class DomCompiler extends RenderCompiler {
7575

7676
_compileView(viewDef: ViewDefinition, templateAndStyles: TemplateAndStyles,
7777
protoViewType: ViewType): Promise<ProtoViewDto> {
78-
if (viewDef.encapsulation === ViewEncapsulation.EMULATED &&
78+
if (viewDef.encapsulation === ViewEncapsulation.Emulated &&
7979
templateAndStyles.styles.length === 0) {
8080
viewDef = this._normalizeViewEncapsulationIfThereAreNoStyles(viewDef);
8181
}
@@ -84,7 +84,7 @@ export class DomCompiler extends RenderCompiler {
8484
var compiledStyles = pipeline.processStyles(templateAndStyles.styles);
8585
var compileElements = pipeline.processElements(
8686
this._createTemplateElm(templateAndStyles.template), protoViewType, viewDef);
87-
if (viewDef.encapsulation === ViewEncapsulation.NATIVE) {
87+
if (viewDef.encapsulation === ViewEncapsulation.Native) {
8888
prependAll(DOM.content(compileElements[0].element),
8989
compiledStyles.map(style => DOM.createStyleElement(style)));
9090
} else {
@@ -107,14 +107,14 @@ export class DomCompiler extends RenderCompiler {
107107
}
108108

109109
_normalizeViewEncapsulationIfThereAreNoStyles(viewDef: ViewDefinition): ViewDefinition {
110-
if (viewDef.encapsulation === ViewEncapsulation.EMULATED) {
110+
if (viewDef.encapsulation === ViewEncapsulation.Emulated) {
111111
return new ViewDefinition({
112112
componentId: viewDef.componentId,
113113
templateAbsUrl: viewDef.templateAbsUrl, template: viewDef.template,
114114
styleAbsUrls: viewDef.styleAbsUrls,
115115
styles: viewDef.styles,
116116
directives: viewDef.directives,
117-
encapsulation: ViewEncapsulation.NONE
117+
encapsulation: ViewEncapsulation.None
118118
});
119119
} else {
120120
return viewDef;

modules/angular2/src/core/render/dom/compiler/style_encapsulator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ export class StyleEncapsulator implements CompileStep {
1515
if (isElementWithTag(current.element, NG_CONTENT_ELEMENT_NAME)) {
1616
current.inheritedProtoView.bindNgContent();
1717
} else {
18-
if (this._view.encapsulation === ViewEncapsulation.EMULATED) {
18+
if (this._view.encapsulation === ViewEncapsulation.Emulated) {
1919
this._processEmulatedScopedElement(current, parent);
2020
}
2121
}
2222
}
2323

2424
processStyle(style: string): string {
2525
var encapsulation = this._view.encapsulation;
26-
if (encapsulation === ViewEncapsulation.EMULATED) {
26+
if (encapsulation === ViewEncapsulation.Emulated) {
2727
return this._shimCssForComponent(style, this._view.componentId);
2828
} else {
2929
return style;

modules/angular2/src/core/render/dom/view/proto_view_builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class ElementBinderBuilder {
189189
throw new BaseException('Only one nested view per element is allowed');
190190
}
191191
this.nestedProtoView =
192-
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.NONE);
192+
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.None);
193193
return this.nestedProtoView;
194194
}
195195

modules/angular2/src/core/render/dom/view/proto_view_merger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function mergeComponent(hostProtoView: ClonedProtoView, binderIdx: number,
193193

194194
// unwrap the fragment elements into arrays of nodes after projecting
195195
var fragments = extractFragmentNodesFromElements(fragmentElements);
196-
var useNativeShadowRoot = nestedProtoView.original.encapsulation === ViewEncapsulation.NATIVE;
196+
var useNativeShadowRoot = nestedProtoView.original.encapsulation === ViewEncapsulation.Native;
197197
if (useNativeShadowRoot) {
198198
targetElementsWithNativeShadowRoot.add(hostElement);
199199
}

modules/angular2/src/web_workers/shared/serializer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export class Serializer {
5757
this._enumRegistry.set(ViewType, viewTypeMap);
5858

5959
var viewEncapsulationMap = new Map<number, any>();
60-
viewEncapsulationMap[0] = ViewEncapsulation.EMULATED;
61-
viewEncapsulationMap[1] = ViewEncapsulation.NATIVE;
62-
viewEncapsulationMap[2] = ViewEncapsulation.NONE;
60+
viewEncapsulationMap[0] = ViewEncapsulation.Emulated;
61+
viewEncapsulationMap[1] = ViewEncapsulation.Native;
62+
viewEncapsulationMap[2] = ViewEncapsulation.None;
6363
this._enumRegistry.set(ViewEncapsulation, viewEncapsulationMap);
6464

6565
var propertyBindingTypeMap = new Map<number, any>();

modules/angular2/test/core/compiler/projection_integration_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ class Simple {
473473
@View({
474474
template: 'SIMPLE(<content></content>)',
475475
directives: [],
476-
encapsulation: ViewEncapsulation.NATIVE
476+
encapsulation: ViewEncapsulation.Native
477477
})
478478
class SimpleNative {
479479
}

modules/angular2/test/core/render/dom/compiler/compiler_common_tests.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ export function runCompilerCommonTests() {
191191
});
192192
}));
193193

194-
it('should store the styles in the SharedStylesHost for ViewEncapsulation.NONE',
194+
it('should store the styles in the SharedStylesHost for ViewEncapsulation.None',
195195
inject([AsyncTestCompleter], (async) => {
196196
var compiler = createCompiler();
197197
compiler.compile(new ViewDefinition({
198198
componentId: 'someComponent',
199199
template: '',
200200
styles: ['a {};'],
201-
encapsulation: ViewEncapsulation.NONE
201+
encapsulation: ViewEncapsulation.None
202202
}))
203203
.then((protoViewDto) => {
204204
expect(DOM.getInnerHTML(templateRoot(protoViewDto))).toEqual('');
@@ -207,14 +207,14 @@ export function runCompilerCommonTests() {
207207
});
208208
}));
209209

210-
it('should store the styles in the SharedStylesHost for ViewEncapsulation.EMULATED',
210+
it('should store the styles in the SharedStylesHost for ViewEncapsulation.Emulated',
211211
inject([AsyncTestCompleter], (async) => {
212212
var compiler = createCompiler();
213213
compiler.compile(new ViewDefinition({
214214
componentId: 'someComponent',
215215
template: '',
216216
styles: ['a {};'],
217-
encapsulation: ViewEncapsulation.EMULATED
217+
encapsulation: ViewEncapsulation.Emulated
218218
}))
219219
.then((protoViewDto) => {
220220
expect(DOM.getInnerHTML(templateRoot(protoViewDto))).toEqual('');
@@ -224,14 +224,14 @@ export function runCompilerCommonTests() {
224224
}));
225225

226226
if (DOM.supportsNativeShadowDOM()) {
227-
it('should store the styles in the template for ViewEncapsulation.NATIVE',
227+
it('should store the styles in the template for ViewEncapsulation.Native',
228228
inject([AsyncTestCompleter], (async) => {
229229
var compiler = createCompiler();
230230
compiler.compile(new ViewDefinition({
231231
componentId: 'someComponent',
232232
template: '',
233233
styles: ['a {};'],
234-
encapsulation: ViewEncapsulation.NATIVE
234+
encapsulation: ViewEncapsulation.Native
235235
}))
236236
.then((protoViewDto) => {
237237
expect(DOM.getInnerHTML(templateRoot(protoViewDto)))
@@ -242,24 +242,24 @@ export function runCompilerCommonTests() {
242242
}));
243243
}
244244

245-
it('should default to ViewEncapsulation.NONE if no styles are specified',
245+
it('should default to ViewEncapsulation.None if no styles are specified',
246246
inject([AsyncTestCompleter], (async) => {
247247
var compiler = createCompiler();
248248
compiler.compile(
249249
new ViewDefinition({componentId: 'someComponent', template: '', styles: []}))
250250
.then((protoView) => {
251-
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.NONE);
251+
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.None);
252252
async.done();
253253
});
254254
}));
255255

256-
it('should default to ViewEncapsulation.EMULATED if styles are specified',
256+
it('should default to ViewEncapsulation.Emulated if styles are specified',
257257
inject([AsyncTestCompleter], (async) => {
258258
var compiler = createCompiler();
259259
compiler.compile(new ViewDefinition(
260260
{componentId: 'someComponent', template: '', styles: ['a {};']}))
261261
.then((protoView) => {
262-
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.EMULATED);
262+
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.Emulated);
263263
async.done();
264264
});
265265
}));

modules/angular2/test/core/render/dom/compiler/pipeline_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function main() {
5353
new MockStep((parent, current, control) => {
5454
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
5555
current.inheritedProtoView =
56-
new ProtoViewBuilder(current.element, ViewType.EMBEDDED, ViewEncapsulation.NONE);
56+
new ProtoViewBuilder(current.element, ViewType.EMBEDDED, ViewEncapsulation.None);
5757
}
5858
})
5959
]);

0 commit comments

Comments
 (0)