diff --git a/packages/enzyme-test-suite/package.json b/packages/enzyme-test-suite/package.json index b4174d852..4611cf8c2 100644 --- a/packages/enzyme-test-suite/package.json +++ b/packages/enzyme-test-suite/package.json @@ -49,4 +49,4 @@ "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.5.1" } -} +} \ No newline at end of file diff --git a/packages/enzyme/src/ShallowWrapper.js b/packages/enzyme/src/ShallowWrapper.js index c07fd4586..44df88f33 100644 --- a/packages/enzyme/src/ShallowWrapper.js +++ b/packages/enzyme/src/ShallowWrapper.js @@ -99,6 +99,10 @@ function getRootNode(node) { return node.rendered; } +function getRootNodeInternal(wrapper) { + return wrapper[ROOT][NODE]; +} + function privateSetNodes(wrapper, nodes) { if (!Array.isArray(nodes)) { privateSet(wrapper, NODE, nodes); @@ -152,10 +156,6 @@ class ShallowWrapper { return this[ROOT]; } - getRootNodeInternal() { - return this[ROOT][NODE]; - } - getNodeInternal() { if (this.length !== 1) { throw new Error('ShallowWrapper::getNode() can only be called when wrapping one node'); @@ -805,7 +805,7 @@ class ShallowWrapper { * @returns {ShallowWrapper} */ parents(selector) { - const allParents = this.wrap(this.single('parents', n => parentsOfNode(n, this.getRootNodeInternal()))); + const allParents = this.wrap(this.single('parents', n => parentsOfNode(n, getRootNodeInternal(this)))); return selector ? allParents.filter(selector) : allParents; }