From b0504724aa717aa31d119c043131a862ee37a5a2 Mon Sep 17 00:00:00 2001 From: Joseph Duncan Date: Mon, 12 Sep 2016 18:10:17 +0200 Subject: [PATCH] fixes #590: change isCompoundSelector to not match prop selector --- src/Utils.js | 2 +- test/ShallowWrapper-spec.jsx | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Utils.js b/src/Utils.js index 15bc375bb..f2ffd3f14 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -189,7 +189,7 @@ export function selectorError(selector, type = '') { ); } -export const isCompoundSelector = /([a-z]\.[a-z]|[a-z]\[.*\]|[a-z]#[a-z])/i; +export const isCompoundSelector = /^(\w+#\w+(\.\w+)*|\.?\w+(\.\w+)+|\w+\[.*\])$/i; const isPropSelector = /^\[.*\]$/; diff --git a/test/ShallowWrapper-spec.jsx b/test/ShallowWrapper-spec.jsx index 47b570f10..7a7eecd27 100644 --- a/test/ShallowWrapper-spec.jsx +++ b/test/ShallowWrapper-spec.jsx @@ -346,6 +346,17 @@ describe('shallow', () => { expect(wrapper.find('.foo').type()).to.equal('input'); }); + it('should find element that has dot in attribute', () => { + const wrapper = shallow( +
+
+
+ ); + + const elements = wrapper.find('[data-baz="foo.bar"]'); + expect(elements.length).to.equal(1); + }); + it('should find an element based on a tag name and class name', () => { const wrapper = shallow(