From a2b70f7712357755664e5638a9dd32cb6f78e3cf Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 21 Mar 2018 13:37:03 +0100 Subject: [PATCH] utils/bind-data-test-attributes: Handle failing `set()` with warning --- addon/utils/bind-data-test-attributes.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/addon/utils/bind-data-test-attributes.js b/addon/utils/bind-data-test-attributes.js index 6d800e38..b63b6705 100644 --- a/addon/utils/bind-data-test-attributes.js +++ b/addon/utils/bind-data-test-attributes.js @@ -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]; @@ -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', + }); + } }