Skip to content

Commit

Permalink
Merge pull request emberjs#14009 from cibernox/fix-attribute-binding-…
Browse files Browse the repository at this point in the history
…for-role

[BUGFIX beta] attributeBindings not working with `role`
  • Loading branch information
rwjblue authored Aug 3, 2016
2 parents ad5d20b + a931cb0 commit 3d25f98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,26 @@ moduleFor('Attribute bindings integration', class extends RenderingTest {

this.assertComponentElement(this.firstChild, { tagName: 'a', attrs: { href: 'unsafe:javascript:alert(\'foo\')' } });
}

['@test it can bind the role attribute (issue #14007)']() {
let FooBarComponent = Component.extend({ attributeBindings: ['role'] });

this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });

this.render('{{foo-bar role=role}}', { role: 'button' });

this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } });

this.runTask(() => this.rerender());

this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } });

this.runTask(() => set(this.context, 'role', 'combobox'));

this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'combobox' } });

this.runTask(() => set(this.context, 'role', null));

this.assertComponentElement(this.firstChild, { tagName: 'div' });
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function normalizeComponentAttributes(component, attrs) {
}
}

normalized.role = buildStatement('get', 'ariaRole');
normalized.role = normalized.role || buildStatement('get', 'ariaRole');

if (attrs.tagName) {
component.tagName = attrs.tagName;
Expand Down

0 comments on commit 3d25f98

Please sign in to comment.