diff --git a/spec/JustNotSorrySpec.test.js b/spec/JustNotSorrySpec.test.js
index 7911891..ac03a1f 100644
--- a/spec/JustNotSorrySpec.test.js
+++ b/spec/JustNotSorrySpec.test.js
@@ -147,6 +147,25 @@ describe('JustNotSorry', () => {
expect(wrapper.state('parentNode')).toBe(domNode.parentNode);
});
+ describe('when there are top-level and child nodes', () => {
+ it('catches the warnings for both', () => {
+ const elem = mount(
+
+ );
+
+ const domNode = elem.getDOMNode();
+ instance.updateWarnings(domNode, [
+ buildWarning('\\b!{3,}\\B', 'warning message'),
+ ]);
+
+ expect(wrapper.state('warnings').length).toBe(2);
+ expect(wrapper.state('parentNode')).toBe(domNode.parentNode);
+ });
+ });
+
it('does not add warnings for tooltip matches', () => {
const node = enterText('test justify test');
simulateEvent(node, 'focus');
diff --git a/src/components/JustNotSorry.js b/src/components/JustNotSorry.js
index 4a33293..ecd87cf 100644
--- a/src/components/JustNotSorry.js
+++ b/src/components/JustNotSorry.js
@@ -43,8 +43,8 @@ class JustNotSorry extends Component {
updateWarnings(email, patterns) {
const newWarnings =
- email.children.length > 0
- ? Array.from(email.children)
+ email.childNodes.length > 0
+ ? Array.from(email.childNodes)
.filter((node) => node.textContent !== '')
.flatMap((text) => findRanges(text, patterns))
: findRanges(email, patterns);