fix(core): fix type error in setElementProperty
Convert propertyValue to string when calling setElementAttribute. Closes #3279
This commit is contained in:
parent
78fdf9a11f
commit
448264be39
|
@ -147,7 +147,7 @@ export class DomRenderer extends Renderer {
|
||||||
// Reflect the property value as an attribute value with ng-reflect- prefix.
|
// Reflect the property value as an attribute value with ng-reflect- prefix.
|
||||||
if (this._reflectPropertiesAsAttributes) {
|
if (this._reflectPropertiesAsAttributes) {
|
||||||
this.setElementAttribute(location, `${REFLECT_PREFIX}${camelCaseToDashCase(propertyName)}`,
|
this.setElementAttribute(location, `${REFLECT_PREFIX}${camelCaseToDashCase(propertyName)}`,
|
||||||
propertyValue);
|
`${propertyValue}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,26 @@ export function main() {
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should reflect non-string property values as attributes if flag is set',
|
||||||
|
inject([AsyncTestCompleter, DomTestbed], (async, tb) => {
|
||||||
|
tb.compileAndMerge(someComponent,
|
||||||
|
[
|
||||||
|
new ViewDefinition({
|
||||||
|
componentId: 'someComponent',
|
||||||
|
template: '<input [title]="y">',
|
||||||
|
directives: []
|
||||||
|
})
|
||||||
|
])
|
||||||
|
.then((protoViewMergeMappings) => {
|
||||||
|
var rootView = tb.createView(protoViewMergeMappings);
|
||||||
|
var el = DOM.childNodes(rootView.hostElement)[0];
|
||||||
|
tb.renderer.setElementProperty(elRef(rootView.viewRef, 1), 'maxLength', 20);
|
||||||
|
expect(DOM.getAttribute(<HTMLInputElement>el, 'ng-reflect-max-length'))
|
||||||
|
.toEqual('20');
|
||||||
|
async.done();
|
||||||
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (DOM.supportsDOMEvents()) {
|
if (DOM.supportsDOMEvents()) {
|
||||||
|
|
Loading…
Reference in New Issue