Skip to content

Commit

Permalink
utils/bind-data-test-attributes: Handle failing set() with warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Mar 21, 2018
1 parent 9216c46 commit a2b70f7
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions addon/utils/bind-data-test-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ export default function bindDataTestAttributes(component) {
return;
}

let computedBindings = component.attributeBindings && component.attributeBindings.isDescriptor;
if (computedBindings) {
let message = `ember-test-selectors could not bind data-test-* properties on ${component} ` +
`automatically because attributeBindings is a computed property.`;

warn(message, false, {
id: 'ember-test-selectors.computed-attribute-bindings',
});

return;
}

let attributeBindings = component.getWithDefault('attributeBindings', []);
if (!isArray(attributeBindings)) {
attributeBindings = [attributeBindings];
Expand All @@ -48,5 +36,15 @@ export default function bindDataTestAttributes(component) {

dataTestProperties.forEach(it => attributeBindings.push(it));

component.set('attributeBindings', attributeBindings);
try {
component.set('attributeBindings', attributeBindings);

} catch (error) {
let message = `ember-test-selectors could not bind data-test-* properties on ${component} ` +
`automatically because "attributeBindings" is a read-only property.`;

warn(message, false, {
id: 'ember-test-selectors.computed-attribute-bindings',
});
}
}

0 comments on commit a2b70f7

Please sign in to comment.