feat(ivy): support host properties in DebugElement.properties (#28355)
DebugElement.properties should contain a map of element property names to element property values, with entries for both normal property bindings and host bindings. Many Angular core tests depend on this map being present. This commit adds support for host property bindings in DebugElement.properties, which fixes the Angular core tests. There is still work to be done for normal property bindings. PR Close #28355
This commit is contained in:

committed by
Jason Aden

parent
c522e03fe9
commit
46aec4a58f
@ -239,14 +239,35 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugEleme
|
||||
|
||||
get name(): string { return this.nativeElement !.nodeName; }
|
||||
|
||||
/**
|
||||
* Returns a map of property names to property values for an element.
|
||||
*
|
||||
* This map includes:
|
||||
* - Regular property bindings (e.g. `[id]="id"`) - TODO
|
||||
* - Host property bindings (e.g. `host: { '[id]': "id" }`)
|
||||
* - Interpolated property bindings (e.g. `id="{{ value }}") - TODO
|
||||
*
|
||||
* It should NOT include input property bindings or attribute bindings.
|
||||
*/
|
||||
get properties(): {[key: string]: any;} {
|
||||
const context = loadLContext(this.nativeNode) !;
|
||||
const lView = context.lView;
|
||||
const tView = lView[TVIEW];
|
||||
const tNode = tView.data[context.nodeIndex] as TNode;
|
||||
const properties = {};
|
||||
// TODO: https://angular-team.atlassian.net/browse/FW-681
|
||||
// Missing implementation here...
|
||||
const tData = lView[TVIEW].data;
|
||||
const tNode = tData[context.nodeIndex] as TNode;
|
||||
|
||||
// TODO(kara): include regular property binding values (not just host properties)
|
||||
const properties: {[key: string]: string} = {};
|
||||
|
||||
// Host binding values for a node are stored after directives on that node
|
||||
let index = tNode.directiveEnd;
|
||||
let propertyName = tData[index];
|
||||
|
||||
// When we reach a value in TView.data that is not a string, we know we've
|
||||
// hit the next node's providers and directives and should stop copying data.
|
||||
while (typeof propertyName === 'string') {
|
||||
properties[propertyName] = lView[index];
|
||||
propertyName = tData[++index];
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user