Skip to content

Commit 5654f2f

Browse files
committed
test(dom_renderer): test that properties on the root element can be changed.
Closes angular#3013 Closes angular#3085
1 parent b123159 commit 5654f2f

1 file changed

Lines changed: 25 additions & 20 deletions

File tree

modules/angular2/test/render/dom/dom_renderer_integration_spec.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export function main() {
6161
});
6262
}));
6363

64-
it('should update any element property/attributes/class/style independent of the compilation',
64+
65+
it('should update any element property/attributes/class/style independent of the compilation on the root element and other elements',
6566
inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => {
6667
tb.compileAndMerge(someComponent,
6768
[
@@ -72,26 +73,30 @@ export function main() {
7273
})
7374
])
7475
.then((protoViewMergeMappings) => {
75-
var rootView = tb.createView(protoViewMergeMappings[0]);
7676

77-
var elr = elRef(rootView.viewRef, 1);
78-
var el = DOM.childNodes(rootView.hostElement)[0];
79-
tb.renderer.setElementProperty(elr, 'value', 'hello');
80-
expect((<HTMLInputElement>el).value).toEqual('hello');
81-
82-
tb.renderer.setElementClass(elr, 'a', true);
83-
expect((<HTMLInputElement>DOM.childNodes(rootView.hostElement)[0]).value)
84-
.toEqual('hello');
85-
tb.renderer.setElementClass(elr, 'a', false);
86-
expect(DOM.hasClass(el, 'a')).toBe(false);
87-
88-
tb.renderer.setElementStyle(elr, 'width', '10px');
89-
expect(DOM.getStyle(el, 'width')).toEqual('10px');
90-
tb.renderer.setElementStyle(elr, 'width', null);
91-
expect(DOM.getStyle(el, 'width')).toEqual('');
92-
93-
tb.renderer.setElementAttribute(elr, 'someAttr', 'someValue');
94-
expect(DOM.getAttribute(el, 'some-attr')).toEqual('someValue');
77+
var checkSetters = (elr, el) => {
78+
tb.renderer.setElementProperty(elr, 'tabIndex', 1);
79+
expect((<HTMLInputElement>el).tabIndex).toEqual(1);
80+
81+
tb.renderer.setElementClass(elr, 'a', true);
82+
expect(DOM.hasClass(el, 'a')).toBe(true);
83+
tb.renderer.setElementClass(elr, 'a', false);
84+
expect(DOM.hasClass(el, 'a')).toBe(false);
85+
86+
tb.renderer.setElementStyle(elr, 'width', '10px');
87+
expect(DOM.getStyle(el, 'width')).toEqual('10px');
88+
tb.renderer.setElementStyle(elr, 'width', null);
89+
expect(DOM.getStyle(el, 'width')).toEqual('');
90+
91+
tb.renderer.setElementAttribute(elr, 'someAttr', 'someValue');
92+
expect(DOM.getAttribute(el, 'some-attr')).toEqual('someValue');
93+
};
94+
95+
var rootView = tb.createView(protoViewMergeMappings[0]);
96+
// root element
97+
checkSetters(elRef(rootView.viewRef, 0), rootView.hostElement);
98+
// nested elements
99+
checkSetters(elRef(rootView.viewRef, 1), DOM.firstChild(rootView.hostElement));
95100

96101
async.done();
97102
});

0 commit comments

Comments
 (0)