Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(testing-library__dom): monkey patched testing-library__dom mirror
- Loading branch information
Showing
11 changed files
with
655 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dom.js |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// TypeScript Version: 2.8 | ||
export * from '@testing-library/dom'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HTMLElement.prototype.querySelectorAllWithShadowDOM = function(query) { | ||
const isNotCustomElementParent = this.tagName.search('-') === -1; | ||
const children = [...(this.children || [])].filter( | ||
(child) => isNotCustomElementParent || !!child.assignedSlot | ||
); | ||
let results = children.filter((el) => el.matches(query)); | ||
if (this.shadowRoot) { | ||
results = results.concat([ | ||
...(this.shadowRoot.querySelectorAllWithShadowDOM(query) || []), | ||
]); | ||
} | ||
children.map((child) => { | ||
if (child.querySelectorAllWithShadowDOM) { | ||
results = results.concat([ | ||
...(child.querySelectorAllWithShadowDOM(query) || []), | ||
]); | ||
} | ||
}); | ||
return results; | ||
}; | ||
|
||
ShadowRoot.prototype.querySelectorAllWithShadowDOM = function(query) { | ||
const children = [...(this.children || [])]; | ||
let results = children.filter((el) => el.matches(query)); | ||
children.map((child) => { | ||
results = results.concat([ | ||
...(child.querySelectorAllWithShadowDOM(query) || []), | ||
]); | ||
}); | ||
return results; | ||
}; | ||
|
||
export * from './dom.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "testing-library__dom", | ||
"version": "7.20.1", | ||
"description": "mirror of @testing-library/dom, bundled and exposed as ES module", | ||
"author": "", | ||
"main": "index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/bundled-es-modules/testing-library-dom.git" | ||
}, | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@rollup/plugin-alias": "^2.2.0", | ||
"@rollup/plugin-replace": "^2.2.1", | ||
"@testing-library/dom": "^7.20.1", | ||
"babel-core": "^6.26.3", | ||
"core-js": "^2.5.7", | ||
"rollup": "^1.0.0", | ||
"rollup-plugin-commonjs": "^9.0.0", | ||
"rollup-plugin-copy": "^3.0.0", | ||
"rollup-plugin-ignore": "^1.0.5", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"rollup-plugin-node-globals": "^1.4.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"rollup-plugin-replace": "^2.1.0", | ||
"semver": ">=4.3.2" | ||
}, | ||
"scripts": { | ||
"build": "rollup -c ./rollup.config.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import replace from '@rollup/plugin-replace'; | ||
|
||
export default [ | ||
{ | ||
input: require.resolve( | ||
'@testing-library/dom/dist/@testing-library/dom.esm.js' | ||
), | ||
output: { | ||
file: './dom.js', | ||
format: 'es', | ||
}, | ||
plugins: [ | ||
resolve({ | ||
browser: true, | ||
preferBuiltins: false, | ||
}), | ||
commonjs(), | ||
replace({ | ||
querySelectorAll: 'querySelectorAllWithShadowDOM', | ||
}), | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.