Skip to content

Commit

Permalink
Merge pull request #11889 from rwjblue/attributeBindings-for-id
Browse files Browse the repository at this point in the history
[BUGFIX release] Fix `attributeBindings` for `id` attribute.
  • Loading branch information
rwjblue committed Jul 25, 2015
2 parents 86d63d4 + 712227c commit 7348ea1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/ember-views/lib/system/build-component-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ function normalizeComponentAttributes(component, isAngleBracket, attrs) {
var attributeBindings = component.attributeBindings;
var i, l;

if (attrs.id && getValue(attrs.id)) {
// Do not allow binding to the `id`
normalized.id = getValue(attrs.id);
component.elementId = normalized.id;
} else {
normalized.id = component.elementId;
}

if (attributeBindings) {
for (i = 0, l = attributeBindings.length; i < l; i++) {
var attr = attributeBindings[i];
Expand Down Expand Up @@ -178,14 +186,6 @@ function normalizeComponentAttributes(component, isAngleBracket, attrs) {
}
}

if (attrs.id && getValue(attrs.id)) {
// Do not allow binding to the `id`
normalized.id = getValue(attrs.id);
component.elementId = normalized.id;
} else {
normalized.id = component.elementId;
}

if (attrs.tagName) {
component.tagName = attrs.tagName;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/ember-views/tests/views/view/attribute_bindings_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,14 @@ QUnit.test('role attribute is not included if not provided', function() {

ok(!view.element.hasAttribute('role'), 'role attribute is not present');
});

QUnit.test('can set id initially via attributeBindings', function() {
view = EmberView.create({
attributeBindings: ['specialSauce:id'],
specialSauce: 'special-sauces-id'
});

appendView();

equal(view.$().attr('id'), 'special-sauces-id', 'id properly used from attributeBindings');
});

0 comments on commit 7348ea1

Please sign in to comment.