fix: small fixes for view engine
This commit is contained in:
parent
e8d2743cfb
commit
6277f16187
|
@ -92,8 +92,9 @@ const ALLOW_DEFAULT_VAR = o.variable(`allowDefault`);
|
||||||
class ViewBuilder implements TemplateAstVisitor, LocalResolver, BuiltinConverterFactory {
|
class ViewBuilder implements TemplateAstVisitor, LocalResolver, BuiltinConverterFactory {
|
||||||
private compType: o.Type;
|
private compType: o.Type;
|
||||||
private nodeDefs: (() => o.Expression)[] = [];
|
private nodeDefs: (() => o.Expression)[] = [];
|
||||||
private purePipeNodeIndices: {[pipeName: string]: number} = {};
|
private purePipeNodeIndices: {[pipeName: string]: number} = Object.create(null);
|
||||||
private refNodeIndices: {[refName: string]: number} = {};
|
// Need Object.create so that we don't have builtin values...
|
||||||
|
private refNodeIndices: {[refName: string]: number} = Object.create(null);
|
||||||
private variables: VariableAst[] = [];
|
private variables: VariableAst[] = [];
|
||||||
private children: ViewBuilder[] = [];
|
private children: ViewBuilder[] = [];
|
||||||
private updateDirectivesExpressions: UpdateExpression[] = [];
|
private updateDirectivesExpressions: UpdateExpression[] = [];
|
||||||
|
@ -929,7 +930,7 @@ function elementBindingDefs(
|
||||||
|
|
||||||
|
|
||||||
function fixedAttrsDef(elementAst: ElementAst): o.Expression {
|
function fixedAttrsDef(elementAst: ElementAst): o.Expression {
|
||||||
const mapResult: {[key: string]: string} = {};
|
const mapResult: {[key: string]: string} = Object.create(null);
|
||||||
elementAst.attrs.forEach(attrAst => { mapResult[attrAst.name] = attrAst.value; });
|
elementAst.attrs.forEach(attrAst => { mapResult[attrAst.name] = attrAst.value; });
|
||||||
elementAst.directives.forEach(dirAst => {
|
elementAst.directives.forEach(dirAst => {
|
||||||
Object.keys(dirAst.directive.hostAttributes).forEach(name => {
|
Object.keys(dirAst.directive.hostAttributes).forEach(name => {
|
||||||
|
|
|
@ -232,8 +232,8 @@ export function createTemplateRef(view: ViewData, def: NodeDef): TemplateRef<any
|
||||||
return new TemplateRef_(view, def);
|
return new TemplateRef_(view, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
class TemplateRef_ implements TemplateRef<any> {
|
class TemplateRef_ extends TemplateRef<any> {
|
||||||
constructor(private _parentView: ViewData, private _def: NodeDef) {}
|
constructor(private _parentView: ViewData, private _def: NodeDef) { super(); }
|
||||||
|
|
||||||
createEmbeddedView(context: any): EmbeddedViewRef<any> {
|
createEmbeddedView(context: any): EmbeddedViewRef<any> {
|
||||||
return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, context));
|
return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, context));
|
||||||
|
|
|
@ -243,7 +243,12 @@ function debugCheckAndUpdateNode(
|
||||||
} else {
|
} else {
|
||||||
// a regular element.
|
// a regular element.
|
||||||
for (let attr in bindingValues) {
|
for (let attr in bindingValues) {
|
||||||
view.renderer.setAttribute(el, attr, bindingValues[attr]);
|
const value = bindingValues[attr];
|
||||||
|
if (value != null) {
|
||||||
|
view.renderer.setAttribute(el, attr, value);
|
||||||
|
} else {
|
||||||
|
view.renderer.removeAttribute(el, attr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +275,7 @@ function camelCaseToDashCase(input: string): string {
|
||||||
function normalizeDebugBindingValue(value: any): string {
|
function normalizeDebugBindingValue(value: any): string {
|
||||||
try {
|
try {
|
||||||
// Limit the size of the value as otherwise the DOM just gets polluted.
|
// Limit the size of the value as otherwise the DOM just gets polluted.
|
||||||
return value ? value.toString().slice(0, 20) : value;
|
return value ? value.toString().slice(0, 30) : value;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return '[ERROR] Exception while trying to serialize the value';
|
return '[ERROR] Exception while trying to serialize the value';
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,11 +176,10 @@ export function splitMatchedQueriesDsl(matchedQueriesDsl: [string | number, Quer
|
||||||
export function getParentRenderElement(view: ViewData, renderHost: any, def: NodeDef): any {
|
export function getParentRenderElement(view: ViewData, renderHost: any, def: NodeDef): any {
|
||||||
let renderParent = def.renderParent;
|
let renderParent = def.renderParent;
|
||||||
if (renderParent) {
|
if (renderParent) {
|
||||||
const parent = def.parent;
|
if (renderParent.type !== NodeType.Element ||
|
||||||
if (parent &&
|
(renderParent.flags & NodeFlags.HasComponent) === 0 ||
|
||||||
(parent.type !== NodeType.Element || (parent.flags & NodeFlags.HasComponent) === 0 ||
|
(renderParent.element.componentRendererType &&
|
||||||
(parent.element.componentRendererType &&
|
renderParent.element.componentRendererType.encapsulation === ViewEncapsulation.Native)) {
|
||||||
parent.element.componentRendererType.encapsulation === ViewEncapsulation.Native))) {
|
|
||||||
// only children of non components, or children of components with native encapsulation should
|
// only children of non components, or children of components with native encapsulation should
|
||||||
// be attached.
|
// be attached.
|
||||||
return asElementData(view, def.renderParent.index).renderElement;
|
return asElementData(view, def.renderParent.index).renderElement;
|
||||||
|
|
Loading…
Reference in New Issue