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:

committed by
Miško Hevery

parent
e916836261
commit
c349bbbc08
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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>();
|
||||
|
Reference in New Issue
Block a user