refactor(ivy): delete ɵɵelementHostAttrs instruction (#34717)

PR Close #34717
This commit is contained in:
Misko Hevery
2020-01-09 21:48:16 -08:00
committed by Miško Hevery
parent 2227d471a4
commit da7e362bce
14 changed files with 219 additions and 265 deletions

View File

@ -830,6 +830,30 @@ describe('host bindings', () => {
expect(hostElement.title).toBe('other title');
});
it('should merge attributes on host and template', () => {
@Directive({selector: '[dir1]', host: {id: 'dir1'}})
class MyDir1 {
}
@Directive({selector: '[dir2]', host: {id: 'dir2'}})
class MyDir2 {
}
@Component({template: `<div dir1 dir2 id="tmpl"></div>`})
class MyComp {
}
TestBed.configureTestingModule({declarations: [MyComp, MyDir1, MyDir2]});
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
const div: HTMLElement = fixture.debugElement.nativeElement.firstChild;
expect(div.id).toEqual(
ivyEnabled ?
// In ivy the correct result is `tmpl` because template has the highest priority.
'tmpl' :
// In VE the order was simply that of execution and so dir2 would win.
'dir2');
});
onlyInIvy('Host bindings do not get merged in ViewEngine')
.it('should work correctly with inherited directives with hostBindings', () => {
@Directive({selector: '[superDir]', host: {'[id]': 'id'}})

View File

@ -191,6 +191,9 @@
{
"name": "callHooks"
},
{
"name": "classIndexOf"
},
{
"name": "concatString"
},
@ -279,7 +282,7 @@
"name": "findAttrIndexInNode"
},
{
"name": "findDirectiveMatches"
"name": "findDirectiveDefMatches"
},
{
"name": "forceStylesAsString"
@ -407,9 +410,6 @@
{
"name": "getStylingMapArray"
},
{
"name": "getTNode"
},
{
"name": "growHostVarsSpace"
},
@ -444,7 +444,7 @@
"name": "incrementInitPhaseFlags"
},
{
"name": "initNodeFlags"
"name": "initTNodeFlags"
},
{
"name": "initializeInputAndOutputAliases"
@ -533,6 +533,12 @@
{
"name": "matchTemplateAttribute"
},
{
"name": "mergeHostAttribute"
},
{
"name": "mergeHostAttrs"
},
{
"name": "nativeAppendChild"
},
@ -638,9 +644,6 @@
{
"name": "setClassName"
},
{
"name": "setCurrentDirectiveDef"
},
{
"name": "setCurrentQueryIndex"
},
@ -719,9 +722,6 @@
{
"name": "ɵɵelementEnd"
},
{
"name": "ɵɵelementHostAttrs"
},
{
"name": "ɵɵelementStart"
},

View File

@ -347,9 +347,6 @@
{
"name": "getStylingMapArray"
},
{
"name": "getTNode"
},
{
"name": "growHostVarsSpace"
},
@ -372,7 +369,7 @@
"name": "incrementInitPhaseFlags"
},
{
"name": "initNodeFlags"
"name": "initTNodeFlags"
},
{
"name": "insertBloom"
@ -518,9 +515,6 @@
{
"name": "setClassName"
},
{
"name": "setCurrentDirectiveDef"
},
{
"name": "setCurrentQueryIndex"
},
@ -572,9 +566,6 @@
{
"name": "ɵɵdefineComponent"
},
{
"name": "ɵɵelementHostAttrs"
},
{
"name": "ɵɵtext"
}

View File

@ -437,6 +437,9 @@
{
"name": "checkNoChangesInternal"
},
{
"name": "classIndexOf"
},
{
"name": "cleanUpView"
},
@ -579,7 +582,7 @@
"name": "findAttrIndexInNode"
},
{
"name": "findDirectiveMatches"
"name": "findDirectiveDefMatches"
},
{
"name": "findExistingListener"
@ -867,7 +870,7 @@
"name": "incrementInitPhaseFlags"
},
{
"name": "initNodeFlags"
"name": "initTNodeFlags"
},
{
"name": "initializeInputAndOutputAliases"
@ -1040,6 +1043,12 @@
{
"name": "matchTemplateAttribute"
},
{
"name": "mergeHostAttribute"
},
{
"name": "mergeHostAttrs"
},
{
"name": "nativeAppendChild"
},
@ -1217,9 +1226,6 @@
{
"name": "setClassName"
},
{
"name": "setCurrentDirectiveDef"
},
{
"name": "setCurrentQueryIndex"
},
@ -1382,9 +1388,6 @@
{
"name": "ɵɵelementEnd"
},
{
"name": "ɵɵelementHostAttrs"
},
{
"name": "ɵɵelementStart"
},

View File

@ -22,7 +22,7 @@ describe('css selector matching', () => {
const tNode = (!attrsOrTNode || Array.isArray(attrsOrTNode)) ?
createTNode(null !, null, TNodeType.Element, 0, tagName, attrsOrTNode as TAttributes) :
(attrsOrTNode as TNode);
return isNodeMatchingSelector(tNode, selector, false);
return isNodeMatchingSelector(tNode, selector, true);
}
describe('isNodeMatchingSimpleSelector', () => {
@ -322,26 +322,6 @@ describe('css selector matching', () => {
// <div class="foo">
expect(isMatching('div', ['class', 'foo'], selector)).toBeFalsy();
});
it('should match against a class value before and after the styling context is created',
() => {
// selector: 'div.abc'
const selector = ['div', SelectorFlags.CLASS, 'abc'];
const tNode = createTNode(null !, null, TNodeType.Element, 0, 'div', []);
// <div> (without attrs or styling context)
expect(isMatching('div', tNode, selector)).toBeFalsy();
// <div class="abc"> (with attrs but without styling context)
tNode.attrs = ['class', 'abc'];
tNode.classes = null;
expect(isMatching('div', tNode, selector)).toBeTruthy();
// <div class="abc"> (with styling context but without attrs)
tNode.classes = ['abc', 'abc', true];
tNode.attrs = null;
expect(isMatching('div', tNode, selector)).toBeTruthy();
});
});
});