Skip to content

Commit 92e5ee4

Browse files
fix: injecting DTL when amd define exists
https://www.ebay.com has a global define function with define.amd as an empty object. This causes the UMD distribution of Dom Testing Library to use the define function to expose it's methods. Since we assume the methods are available on the TestingLibraryDom object this breaks the library. Modify the UMD distribution so it creates the TestingLibraryDom even when a define function exists.
1 parent 0935f14 commit 92e5ee4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const DOM_TESTING_LIBRARY_UMD_PATH = path.join(
3737
const DOM_TESTING_LIBRARY_UMD = fs
3838
.readFileSync(DOM_TESTING_LIBRARY_UMD_PATH)
3939
.toString()
40+
.replace('define.amd', 'false') // Never inject DTL using AMD define function
4041

4142
const SIMMERJS = fs
4243
.readFileSync(require.resolve('simmerjs/dist/simmer.js'))

test-app/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
content: 'Named by pseudo element';
2222
}
2323
</style>
24+
<script>
25+
define = function (){}
26+
define.amd = {}
27+
</script>
2428
</head>
2529

2630
<div>

0 commit comments

Comments
 (0)