From bff661d93489eb7719cbe76354afd945d42d30f6 Mon Sep 17 00:00:00 2001 From: Ben Demboski Date: Tue, 11 Dec 2018 22:39:48 -0800 Subject: [PATCH] Fix attribute edge case Make sure we only strip `data-test-*` selectors, and not `*data-test-*` selectors --- node-tests/fixtures/default/expected.js | 3 ++- node-tests/fixtures/default/expected6.js | 3 ++- node-tests/fixtures/default/expected7.js | 3 ++- node-tests/fixtures/default/fixture.js | 1 + strip-data-test-properties-plugin.js | 2 +- strip-data-test-properties-plugin6.js | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/node-tests/fixtures/default/expected.js b/node-tests/fixtures/default/expected.js index b566bc44..f85bb7c9 100644 --- a/node-tests/fixtures/default/expected.js +++ b/node-tests/fixtures/default/expected.js @@ -12,6 +12,7 @@ var _ember2 = _interopRequireDefault(_ember); exports['default'] = _ember2['default'].Component.extend({ foo: 'foo', - 'data-test': 'test' + 'data-test': 'test', + 'metadata-test-foo': 'metadata' }); module.exports = exports['default']; diff --git a/node-tests/fixtures/default/expected6.js b/node-tests/fixtures/default/expected6.js index 06b896fa..e9a85a3a 100644 --- a/node-tests/fixtures/default/expected6.js +++ b/node-tests/fixtures/default/expected6.js @@ -2,5 +2,6 @@ import Ember from 'ember'; export default Ember.Component.extend({ foo: 'foo', - 'data-test': 'test' + 'data-test': 'test', + 'metadata-test-foo': 'metadata' }); diff --git a/node-tests/fixtures/default/expected7.js b/node-tests/fixtures/default/expected7.js index fd08f86d..73bb5901 100644 --- a/node-tests/fixtures/default/expected7.js +++ b/node-tests/fixtures/default/expected7.js @@ -1,5 +1,6 @@ import Ember from 'ember'; export default Ember.Component.extend({ foo: 'foo', - 'data-test': 'test' + 'data-test': 'test', + 'metadata-test-foo': 'metadata' }); diff --git a/node-tests/fixtures/default/fixture.js b/node-tests/fixtures/default/fixture.js index 2dbfbc59..de6430b4 100644 --- a/node-tests/fixtures/default/fixture.js +++ b/node-tests/fixtures/default/fixture.js @@ -3,6 +3,7 @@ import Ember from 'ember'; export default Ember.Component.extend({ foo: 'foo', 'data-test': 'test', + 'metadata-test-foo': 'metadata', 'data-test-foo': 'foo', 'data-test-foobar': Ember.computed('data-test-foo', function() { return `${this.get('data-test-foo')}bar` diff --git a/strip-data-test-properties-plugin.js b/strip-data-test-properties-plugin.js index 8fab34d5..678f5c4d 100644 --- a/strip-data-test-properties-plugin.js +++ b/strip-data-test-properties-plugin.js @@ -2,7 +2,7 @@ /* eslint-env node */ -let TEST_SELECTOR_PREFIX = /data-test-.*/; +let TEST_SELECTOR_PREFIX = /^data-test-.*/; function StripDataTestPropertiesPlugin(babel) { return new babel.Plugin('ember-test-selectors', { diff --git a/strip-data-test-properties-plugin6.js b/strip-data-test-properties-plugin6.js index ad129f82..62308338 100644 --- a/strip-data-test-properties-plugin6.js +++ b/strip-data-test-properties-plugin6.js @@ -2,7 +2,7 @@ /* eslint-env node */ -let TEST_SELECTOR_PREFIX = /data-test-.*/; +let TEST_SELECTOR_PREFIX = /^data-test-.*/; function StripDataTestPropertiesPlugin() { return {