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:
parent
e916836261
commit
c349bbbc08
|
@ -91,9 +91,9 @@ export class ViewMetadata {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify how the template and the styles should be encapsulated.
|
* 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,
|
* has styles,
|
||||||
* otherwise {@link ViewEncapsulation#NONE `ViewEncapsulation.NONE`}.
|
* otherwise {@link ViewEncapsulation#None `ViewEncapsulation.None`}.
|
||||||
*/
|
*/
|
||||||
encapsulation: ViewEncapsulation;
|
encapsulation: ViewEncapsulation;
|
||||||
|
|
||||||
|
|
|
@ -293,15 +293,15 @@ export enum ViewEncapsulation {
|
||||||
* Emulate scoping of styles by preprocessing the style rules
|
* Emulate scoping of styles by preprocessing the style rules
|
||||||
* and adding additional attributes to elements. This is the default.
|
* 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.
|
* 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.
|
* Don't scope the template nor the styles.
|
||||||
*/
|
*/
|
||||||
NONE
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewDefinition {
|
export class ViewDefinition {
|
||||||
|
@ -329,7 +329,7 @@ export class ViewDefinition {
|
||||||
this.styleAbsUrls = styleAbsUrls;
|
this.styleAbsUrls = styleAbsUrls;
|
||||||
this.styles = styles;
|
this.styles = styles;
|
||||||
this.directives = directives;
|
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,
|
styles: null,
|
||||||
styleAbsUrls: null,
|
styleAbsUrls: null,
|
||||||
directives: [directiveMetadata],
|
directives: [directiveMetadata],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
});
|
});
|
||||||
|
|
||||||
let selector = CssSelector.parse(directiveMetadata.selector)[0];
|
let selector = CssSelector.parse(directiveMetadata.selector)[0];
|
||||||
|
@ -75,7 +75,7 @@ export class DomCompiler extends RenderCompiler {
|
||||||
|
|
||||||
_compileView(viewDef: ViewDefinition, templateAndStyles: TemplateAndStyles,
|
_compileView(viewDef: ViewDefinition, templateAndStyles: TemplateAndStyles,
|
||||||
protoViewType: ViewType): Promise<ProtoViewDto> {
|
protoViewType: ViewType): Promise<ProtoViewDto> {
|
||||||
if (viewDef.encapsulation === ViewEncapsulation.EMULATED &&
|
if (viewDef.encapsulation === ViewEncapsulation.Emulated &&
|
||||||
templateAndStyles.styles.length === 0) {
|
templateAndStyles.styles.length === 0) {
|
||||||
viewDef = this._normalizeViewEncapsulationIfThereAreNoStyles(viewDef);
|
viewDef = this._normalizeViewEncapsulationIfThereAreNoStyles(viewDef);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ export class DomCompiler extends RenderCompiler {
|
||||||
var compiledStyles = pipeline.processStyles(templateAndStyles.styles);
|
var compiledStyles = pipeline.processStyles(templateAndStyles.styles);
|
||||||
var compileElements = pipeline.processElements(
|
var compileElements = pipeline.processElements(
|
||||||
this._createTemplateElm(templateAndStyles.template), protoViewType, viewDef);
|
this._createTemplateElm(templateAndStyles.template), protoViewType, viewDef);
|
||||||
if (viewDef.encapsulation === ViewEncapsulation.NATIVE) {
|
if (viewDef.encapsulation === ViewEncapsulation.Native) {
|
||||||
prependAll(DOM.content(compileElements[0].element),
|
prependAll(DOM.content(compileElements[0].element),
|
||||||
compiledStyles.map(style => DOM.createStyleElement(style)));
|
compiledStyles.map(style => DOM.createStyleElement(style)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,14 +107,14 @@ export class DomCompiler extends RenderCompiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
_normalizeViewEncapsulationIfThereAreNoStyles(viewDef: ViewDefinition): ViewDefinition {
|
_normalizeViewEncapsulationIfThereAreNoStyles(viewDef: ViewDefinition): ViewDefinition {
|
||||||
if (viewDef.encapsulation === ViewEncapsulation.EMULATED) {
|
if (viewDef.encapsulation === ViewEncapsulation.Emulated) {
|
||||||
return new ViewDefinition({
|
return new ViewDefinition({
|
||||||
componentId: viewDef.componentId,
|
componentId: viewDef.componentId,
|
||||||
templateAbsUrl: viewDef.templateAbsUrl, template: viewDef.template,
|
templateAbsUrl: viewDef.templateAbsUrl, template: viewDef.template,
|
||||||
styleAbsUrls: viewDef.styleAbsUrls,
|
styleAbsUrls: viewDef.styleAbsUrls,
|
||||||
styles: viewDef.styles,
|
styles: viewDef.styles,
|
||||||
directives: viewDef.directives,
|
directives: viewDef.directives,
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return viewDef;
|
return viewDef;
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class StyleEncapsulator implements CompileStep {
|
||||||
if (isElementWithTag(current.element, NG_CONTENT_ELEMENT_NAME)) {
|
if (isElementWithTag(current.element, NG_CONTENT_ELEMENT_NAME)) {
|
||||||
current.inheritedProtoView.bindNgContent();
|
current.inheritedProtoView.bindNgContent();
|
||||||
} else {
|
} else {
|
||||||
if (this._view.encapsulation === ViewEncapsulation.EMULATED) {
|
if (this._view.encapsulation === ViewEncapsulation.Emulated) {
|
||||||
this._processEmulatedScopedElement(current, parent);
|
this._processEmulatedScopedElement(current, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export class StyleEncapsulator implements CompileStep {
|
||||||
|
|
||||||
processStyle(style: string): string {
|
processStyle(style: string): string {
|
||||||
var encapsulation = this._view.encapsulation;
|
var encapsulation = this._view.encapsulation;
|
||||||
if (encapsulation === ViewEncapsulation.EMULATED) {
|
if (encapsulation === ViewEncapsulation.Emulated) {
|
||||||
return this._shimCssForComponent(style, this._view.componentId);
|
return this._shimCssForComponent(style, this._view.componentId);
|
||||||
} else {
|
} else {
|
||||||
return style;
|
return style;
|
||||||
|
|
|
@ -189,7 +189,7 @@ export class ElementBinderBuilder {
|
||||||
throw new BaseException('Only one nested view per element is allowed');
|
throw new BaseException('Only one nested view per element is allowed');
|
||||||
}
|
}
|
||||||
this.nestedProtoView =
|
this.nestedProtoView =
|
||||||
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.NONE);
|
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.None);
|
||||||
return this.nestedProtoView;
|
return this.nestedProtoView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ function mergeComponent(hostProtoView: ClonedProtoView, binderIdx: number,
|
||||||
|
|
||||||
// unwrap the fragment elements into arrays of nodes after projecting
|
// unwrap the fragment elements into arrays of nodes after projecting
|
||||||
var fragments = extractFragmentNodesFromElements(fragmentElements);
|
var fragments = extractFragmentNodesFromElements(fragmentElements);
|
||||||
var useNativeShadowRoot = nestedProtoView.original.encapsulation === ViewEncapsulation.NATIVE;
|
var useNativeShadowRoot = nestedProtoView.original.encapsulation === ViewEncapsulation.Native;
|
||||||
if (useNativeShadowRoot) {
|
if (useNativeShadowRoot) {
|
||||||
targetElementsWithNativeShadowRoot.add(hostElement);
|
targetElementsWithNativeShadowRoot.add(hostElement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,9 @@ export class Serializer {
|
||||||
this._enumRegistry.set(ViewType, viewTypeMap);
|
this._enumRegistry.set(ViewType, viewTypeMap);
|
||||||
|
|
||||||
var viewEncapsulationMap = new Map<number, any>();
|
var viewEncapsulationMap = new Map<number, any>();
|
||||||
viewEncapsulationMap[0] = ViewEncapsulation.EMULATED;
|
viewEncapsulationMap[0] = ViewEncapsulation.Emulated;
|
||||||
viewEncapsulationMap[1] = ViewEncapsulation.NATIVE;
|
viewEncapsulationMap[1] = ViewEncapsulation.Native;
|
||||||
viewEncapsulationMap[2] = ViewEncapsulation.NONE;
|
viewEncapsulationMap[2] = ViewEncapsulation.None;
|
||||||
this._enumRegistry.set(ViewEncapsulation, viewEncapsulationMap);
|
this._enumRegistry.set(ViewEncapsulation, viewEncapsulationMap);
|
||||||
|
|
||||||
var propertyBindingTypeMap = new Map<number, any>();
|
var propertyBindingTypeMap = new Map<number, any>();
|
||||||
|
|
|
@ -473,7 +473,7 @@ class Simple {
|
||||||
@View({
|
@View({
|
||||||
template: 'SIMPLE(<content></content>)',
|
template: 'SIMPLE(<content></content>)',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NATIVE
|
encapsulation: ViewEncapsulation.Native
|
||||||
})
|
})
|
||||||
class SimpleNative {
|
class SimpleNative {
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
var compiler = createCompiler();
|
var compiler = createCompiler();
|
||||||
compiler.compile(new ViewDefinition({
|
compiler.compile(new ViewDefinition({
|
||||||
componentId: 'someComponent',
|
componentId: 'someComponent',
|
||||||
template: '',
|
template: '',
|
||||||
styles: ['a {};'],
|
styles: ['a {};'],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
}))
|
}))
|
||||||
.then((protoViewDto) => {
|
.then((protoViewDto) => {
|
||||||
expect(DOM.getInnerHTML(templateRoot(protoViewDto))).toEqual('');
|
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) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
var compiler = createCompiler();
|
var compiler = createCompiler();
|
||||||
compiler.compile(new ViewDefinition({
|
compiler.compile(new ViewDefinition({
|
||||||
componentId: 'someComponent',
|
componentId: 'someComponent',
|
||||||
template: '',
|
template: '',
|
||||||
styles: ['a {};'],
|
styles: ['a {};'],
|
||||||
encapsulation: ViewEncapsulation.EMULATED
|
encapsulation: ViewEncapsulation.Emulated
|
||||||
}))
|
}))
|
||||||
.then((protoViewDto) => {
|
.then((protoViewDto) => {
|
||||||
expect(DOM.getInnerHTML(templateRoot(protoViewDto))).toEqual('');
|
expect(DOM.getInnerHTML(templateRoot(protoViewDto))).toEqual('');
|
||||||
|
@ -224,14 +224,14 @@ export function runCompilerCommonTests() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (DOM.supportsNativeShadowDOM()) {
|
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) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
var compiler = createCompiler();
|
var compiler = createCompiler();
|
||||||
compiler.compile(new ViewDefinition({
|
compiler.compile(new ViewDefinition({
|
||||||
componentId: 'someComponent',
|
componentId: 'someComponent',
|
||||||
template: '',
|
template: '',
|
||||||
styles: ['a {};'],
|
styles: ['a {};'],
|
||||||
encapsulation: ViewEncapsulation.NATIVE
|
encapsulation: ViewEncapsulation.Native
|
||||||
}))
|
}))
|
||||||
.then((protoViewDto) => {
|
.then((protoViewDto) => {
|
||||||
expect(DOM.getInnerHTML(templateRoot(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) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
var compiler = createCompiler();
|
var compiler = createCompiler();
|
||||||
compiler.compile(
|
compiler.compile(
|
||||||
new ViewDefinition({componentId: 'someComponent', template: '', styles: []}))
|
new ViewDefinition({componentId: 'someComponent', template: '', styles: []}))
|
||||||
.then((protoView) => {
|
.then((protoView) => {
|
||||||
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.NONE);
|
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.None);
|
||||||
async.done();
|
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) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
var compiler = createCompiler();
|
var compiler = createCompiler();
|
||||||
compiler.compile(new ViewDefinition(
|
compiler.compile(new ViewDefinition(
|
||||||
{componentId: 'someComponent', template: '', styles: ['a {};']}))
|
{componentId: 'someComponent', template: '', styles: ['a {};']}))
|
||||||
.then((protoView) => {
|
.then((protoView) => {
|
||||||
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.EMULATED);
|
expect(mockStepFactory.viewDef.encapsulation).toBe(ViewEncapsulation.Emulated);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -53,7 +53,7 @@ export function main() {
|
||||||
new MockStep((parent, current, control) => {
|
new MockStep((parent, current, control) => {
|
||||||
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
|
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
|
||||||
current.inheritedProtoView =
|
current.inheritedProtoView =
|
||||||
new ProtoViewBuilder(current.element, ViewType.EMBEDDED, ViewEncapsulation.NONE);
|
new ProtoViewBuilder(current.element, ViewType.EMBEDDED, ViewEncapsulation.None);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -62,38 +62,38 @@ export function main() {
|
||||||
return compileElements[0].inheritedProtoView;
|
return compileElements[0].inheritedProtoView;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('ViewEncapsulation.NONE', () => {
|
describe('ViewEncapsulation.None', () => {
|
||||||
it('should not change the styles', () => {
|
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 {}');
|
expect(cs[0]).toEqual('.one {}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ViewEncapsulation.NATIVE', () => {
|
describe('ViewEncapsulation.Native', () => {
|
||||||
it('should not change the styles', () => {
|
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 {}');
|
expect(cs[0]).toEqual('.one {}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ViewEncapsulation.EMULATED', () => {
|
describe('ViewEncapsulation.Emulated', () => {
|
||||||
it('should scope styles', () => {
|
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}");
|
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', () => {
|
it('should return the same style given the same component', () => {
|
||||||
var style = '.foo {} :host {}';
|
var style = '.foo {} :host {}';
|
||||||
var cs1 = processStyles(ViewEncapsulation.EMULATED, 'someComponent', [style]);
|
var cs1 = processStyles(ViewEncapsulation.Emulated, 'someComponent', [style]);
|
||||||
var cs2 = processStyles(ViewEncapsulation.EMULATED, 'someComponent', [style]);
|
var cs2 = processStyles(ViewEncapsulation.Emulated, 'someComponent', [style]);
|
||||||
|
|
||||||
expect(cs1[0]).toEqual(cs2[0]);
|
expect(cs1[0]).toEqual(cs2[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return different styles given different components', () => {
|
it('should return different styles given different components', () => {
|
||||||
var style = '.foo {} :host {}';
|
var style = '.foo {} :host {}';
|
||||||
var cs1 = processStyles(ViewEncapsulation.EMULATED, 'someComponent1', [style]);
|
var cs1 = processStyles(ViewEncapsulation.Emulated, 'someComponent1', [style]);
|
||||||
var cs2 = processStyles(ViewEncapsulation.EMULATED, 'someComponent2', [style]);
|
var cs2 = processStyles(ViewEncapsulation.Emulated, 'someComponent2', [style]);
|
||||||
|
|
||||||
expect(cs1[0]).not.toEqual(cs2[0]);
|
expect(cs1[0]).not.toEqual(cs2[0]);
|
||||||
});
|
});
|
||||||
|
@ -101,13 +101,13 @@ export function main() {
|
||||||
it('should add a host attribute to component proto views', () => {
|
it('should add a host attribute to component proto views', () => {
|
||||||
var template = DOM.createTemplate('<div></div>');
|
var template = DOM.createTemplate('<div></div>');
|
||||||
var protoViewBuilder =
|
var protoViewBuilder =
|
||||||
processElements(ViewEncapsulation.EMULATED, 'someComponent', template);
|
processElements(ViewEncapsulation.Emulated, 'someComponent', template);
|
||||||
expect(protoViewBuilder.hostAttributes.get('_nghost-someapp-0')).toEqual('');
|
expect(protoViewBuilder.hostAttributes.get('_nghost-someapp-0')).toEqual('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not add a host attribute to embedded proto views', () => {
|
it('should not add a host attribute to embedded proto views', () => {
|
||||||
var template = DOM.createTemplate('<div></div>');
|
var template = DOM.createTemplate('<div></div>');
|
||||||
var protoViewBuilder = processElements(ViewEncapsulation.EMULATED, 'someComponent',
|
var protoViewBuilder = processElements(ViewEncapsulation.Emulated, 'someComponent',
|
||||||
template, ViewType.EMBEDDED);
|
template, ViewType.EMBEDDED);
|
||||||
expect(protoViewBuilder.hostAttributes.size).toBe(0);
|
expect(protoViewBuilder.hostAttributes.size).toBe(0);
|
||||||
});
|
});
|
||||||
|
@ -115,19 +115,19 @@ export function main() {
|
||||||
it('should not add a host attribute to host proto views', () => {
|
it('should not add a host attribute to host proto views', () => {
|
||||||
var template = DOM.createTemplate('<div></div>');
|
var template = DOM.createTemplate('<div></div>');
|
||||||
var protoViewBuilder =
|
var protoViewBuilder =
|
||||||
processElements(ViewEncapsulation.EMULATED, 'someComponent', template, ViewType.HOST);
|
processElements(ViewEncapsulation.Emulated, 'someComponent', template, ViewType.HOST);
|
||||||
expect(protoViewBuilder.hostAttributes.size).toBe(0);
|
expect(protoViewBuilder.hostAttributes.size).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add an attribute to the content elements', () => {
|
it('should add an attribute to the content elements', () => {
|
||||||
var template = DOM.createTemplate('<div></div>');
|
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>');
|
expect(DOM.getInnerHTML(template)).toEqual('<div _ngcontent-someapp-0=""></div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not add an attribute to the content elements for host views', () => {
|
it('should not add an attribute to the content elements for host views', () => {
|
||||||
var template = DOM.createTemplate('<div></div>');
|
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>');
|
expect(DOM.getInnerHTML(template)).toEqual('<div></div>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -215,7 +215,7 @@ export function main() {
|
||||||
componentId: 'someComponent',
|
componentId: 'someComponent',
|
||||||
template: 'hello',
|
template: 'hello',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NATIVE
|
encapsulation: ViewEncapsulation.Native
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
.then((protoViewMergeMappings) => {
|
.then((protoViewMergeMappings) => {
|
||||||
|
@ -234,7 +234,7 @@ export function main() {
|
||||||
componentId: 'someComponent',
|
componentId: 'someComponent',
|
||||||
template: '',
|
template: '',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NATIVE,
|
encapsulation: ViewEncapsulation.Native,
|
||||||
styles: ['a {};']
|
styles: ['a {};']
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
|
@ -244,7 +244,7 @@ export function main() {
|
||||||
componentId: 'someComponent',
|
componentId: 'someComponent',
|
||||||
template: '',
|
template: '',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
styles: ['b {};']
|
styles: ['b {};']
|
||||||
}))
|
}))
|
||||||
.then(_ => {
|
.then(_ => {
|
||||||
|
@ -254,7 +254,7 @@ export function main() {
|
||||||
componentId: 'someComponent',
|
componentId: 'someComponent',
|
||||||
template: '',
|
template: '',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
styles: ['c {};']
|
styles: ['c {};']
|
||||||
}))
|
}))
|
||||||
.then(_ => {
|
.then(_ => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export function main() {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
templateCloner = new TemplateCloner(-1);
|
templateCloner = new TemplateCloner(-1);
|
||||||
builder =
|
builder =
|
||||||
new ProtoViewBuilder(DOM.createTemplate(''), ViewType.EMBEDDED, ViewEncapsulation.NONE);
|
new ProtoViewBuilder(DOM.createTemplate(''), ViewType.EMBEDDED, ViewEncapsulation.None);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!IS_DART) {
|
if (!IS_DART) {
|
||||||
|
|
|
@ -264,7 +264,7 @@ export function main() {
|
||||||
tb.compiler.compileHost(rootDirective('root'))
|
tb.compiler.compileHost(rootDirective('root'))
|
||||||
.then((rootProtoViewDto) => {
|
.then((rootProtoViewDto) => {
|
||||||
var builder = new ProtoViewBuilder(DOM.createTemplate(''), ViewType.COMPONENT,
|
var builder = new ProtoViewBuilder(DOM.createTemplate(''), ViewType.COMPONENT,
|
||||||
ViewEncapsulation.NONE);
|
ViewEncapsulation.None);
|
||||||
builder.setHostAttribute('a', 'b');
|
builder.setHostAttribute('a', 'b');
|
||||||
var componentProtoViewDto = builder.build(new ElementSchemaRegistry(), cloner);
|
var componentProtoViewDto = builder.build(new ElementSchemaRegistry(), cloner);
|
||||||
tb.merge([rootProtoViewDto, componentProtoViewDto])
|
tb.merge([rootProtoViewDto, componentProtoViewDto])
|
||||||
|
@ -294,8 +294,8 @@ function runAndAssert(hostElementName: string, componentTemplates: string[],
|
||||||
cloner: TemplateCloner) => {
|
cloner: TemplateCloner) => {
|
||||||
tb.compileAndMerge(rootComp, componentTemplates.map(template => componentView(
|
tb.compileAndMerge(rootComp, componentTemplates.map(template => componentView(
|
||||||
template, useNativeEncapsulation ?
|
template, useNativeEncapsulation ?
|
||||||
ViewEncapsulation.NATIVE :
|
ViewEncapsulation.Native :
|
||||||
ViewEncapsulation.NONE)))
|
ViewEncapsulation.None)))
|
||||||
.then((mergeMappings) => {
|
.then((mergeMappings) => {
|
||||||
expect(stringify(cloner, mergeMappings)).toEqual(expectedFragments);
|
expect(stringify(cloner, mergeMappings)).toEqual(expectedFragments);
|
||||||
async.done();
|
async.done();
|
||||||
|
@ -309,7 +309,7 @@ function rootDirective(hostElementName: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function componentView(template: string,
|
function componentView(template: string,
|
||||||
encapsulation: ViewEncapsulation = ViewEncapsulation.NONE) {
|
encapsulation: ViewEncapsulation = ViewEncapsulation.None) {
|
||||||
return new ViewDefinition({
|
return new ViewDefinition({
|
||||||
componentId: 'someComp',
|
componentId: 'someComp',
|
||||||
template: template,
|
template: template,
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {isPresent} from 'angular2/src/core/facade/lang';
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/button/button.html',
|
templateUrl: 'package:angular2_material/src/components/button/button.html',
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
export class MdButton {
|
export class MdButton {
|
||||||
/** Whether a mousedown has occured on this element in the last 100ms. */
|
/** Whether a mousedown has occured on this element in the last 100ms. */
|
||||||
|
@ -61,7 +61,7 @@ export class MdButton {
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/button/button.html',
|
templateUrl: 'package:angular2_material/src/components/button/button.html',
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdAnchor extends MdButton {
|
export class MdAnchor extends MdButton {
|
||||||
tabIndex: number;
|
tabIndex: number;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import {NumberWrapper} from 'angular2/src/core/facade/lang';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/checkbox/checkbox.html',
|
templateUrl: 'package:angular2_material/src/components/checkbox/checkbox.html',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdCheckbox {
|
export class MdCheckbox {
|
||||||
/** Whether this checkbox is checked. */
|
/** Whether this checkbox is checked. */
|
||||||
|
|
|
@ -210,7 +210,7 @@ export class MdDialogConfig {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
templateUrl: 'package:angular2_material/src/components/dialog/dialog.html',
|
templateUrl: 'package:angular2_material/src/components/dialog/dialog.html',
|
||||||
directives: [forwardRef(() => MdDialogContent)]
|
directives: [forwardRef(() => MdDialogContent)]
|
||||||
})
|
})
|
||||||
|
@ -258,7 +258,7 @@ class MdDialogContent {
|
||||||
'(click)': 'onClick()',
|
'(click)': 'onClick()',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@View({template: '', encapsulation: ViewEncapsulation.NONE})
|
@View({template: '', encapsulation: ViewEncapsulation.None})
|
||||||
class MdBackdrop {
|
class MdBackdrop {
|
||||||
dialogRef: MdDialogRef;
|
dialogRef: MdDialogRef;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class RowHeightMode {
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/grid_list/grid_list.html',
|
templateUrl: 'package:angular2_material/src/components/grid_list/grid_list.html',
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdGridList {
|
export class MdGridList {
|
||||||
/** Array of tiles that are being rendered. */
|
/** Array of tiles that are being rendered. */
|
||||||
|
@ -230,7 +230,7 @@ export class MdGridList {
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/grid_list/grid_tile.html',
|
templateUrl: 'package:angular2_material/src/components/grid_list/grid_tile.html',
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdGridTile {
|
export class MdGridTile {
|
||||||
gridList: MdGridList;
|
gridList: MdGridList;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Component, View, ViewEncapsulation} from 'angular2/angular2';
|
||||||
@Component({selector: 'md-progress-circular'})
|
@Component({selector: 'md-progress-circular'})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/progress-circular/progress_circular.html',
|
templateUrl: 'package:angular2_material/src/components/progress-circular/progress_circular.html',
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdProgressCircular {
|
export class MdProgressCircular {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ProgressMode {
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/progress-linear/progress_linear.html',
|
templateUrl: 'package:angular2_material/src/components/progress-linear/progress_linear.html',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdProgressLinear {
|
export class MdProgressLinear {
|
||||||
/** Value for the primary bar. */
|
/** Value for the primary bar. */
|
||||||
|
|
|
@ -47,7 +47,7 @@ var _uniqueIdCounter: number = 0;
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/radio/radio_group.html',
|
templateUrl: 'package:angular2_material/src/components/radio/radio_group.html',
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdRadioGroup {
|
export class MdRadioGroup {
|
||||||
/** The selected value for the radio group. The value comes from the options. */
|
/** The selected value for the radio group. The value comes from the options. */
|
||||||
|
@ -205,7 +205,7 @@ export class MdRadioGroup {
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/radio/radio_button.html',
|
templateUrl: 'package:angular2_material/src/components/radio/radio_button.html',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdRadioButton {
|
export class MdRadioButton {
|
||||||
/** Whether this radio is checked. */
|
/** Whether this radio is checked. */
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {MdCheckbox} from "../checkbox/checkbox";
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/switcher/switch.html',
|
templateUrl: 'package:angular2_material/src/components/switcher/switch.html',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MdSwitch extends MdCheckbox {
|
export class MdSwitch extends MdCheckbox {
|
||||||
constructor(@Attribute('tabindex') tabindex: string) {
|
constructor(@Attribute('tabindex') tabindex: string) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [MdButton, MdAnchor, NgFor],
|
directives: [MdButton, MdAnchor, NgFor],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
previousClick: string;
|
previousClick: string;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [MdCheckbox],
|
directives: [MdCheckbox],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
toggleCount: number;
|
toggleCount: number;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import {isPresent} from 'angular2/src/core/facade/lang';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [],
|
directives: [],
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
dialog: MdDialog;
|
dialog: MdDialog;
|
||||||
|
@ -70,7 +70,7 @@ class DemoApp {
|
||||||
properties: ['numCoconuts'],
|
properties: ['numCoconuts'],
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
template: `
|
template: `
|
||||||
<h2>This is the dialog content</h2>
|
<h2>This is the dialog content</h2>
|
||||||
<p>There are {{numCoconuts}} coconuts.</p>
|
<p>There are {{numCoconuts}} coconuts.</p>
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [MdGridList, MdGridTile],
|
directives: [MdGridList, MdGridTile],
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
tile3RowSpan: number;
|
tile3RowSpan: number;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {bind} from 'angular2/di';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [MdInputContainer, MdInput],
|
directives: [MdInputContainer, MdInput],
|
||||||
encapsulation: ViewEncapsulation.NONE
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [MdProgressLinear],
|
directives: [MdProgressLinear],
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
progress: number;
|
progress: number;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {bind} from 'angular2/di';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [MdRadioGroup, MdRadioButton],
|
directives: [MdRadioGroup, MdRadioButton],
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
thirdValue;
|
thirdValue;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {bind} from 'angular2/di';
|
||||||
@View({
|
@View({
|
||||||
templateUrl: './demo_app.html',
|
templateUrl: './demo_app.html',
|
||||||
directives: [MdSwitch],
|
directives: [MdSwitch],
|
||||||
encapsulation: ViewEncapsulation.NONE,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
class DemoApp {
|
class DemoApp {
|
||||||
toggleCount: number;
|
toggleCount: number;
|
||||||
|
|
Loading…
Reference in New Issue