File tree 5 files changed +21
-19
lines changed 5 files changed +21
-19
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ when a real user uses it.
89
89
* [ TextMatch Examples] ( #textmatch-examples )
90
90
* [ ` query ` APIs] ( #query-apis )
91
91
* [ ` queryAll ` and ` getAll ` APIs] ( #queryall-and-getall-apis )
92
- * [ ` bindElementToQueries ` ] ( #bindelementtoqueries )
92
+ * [ ` getQueriesForElement ` ] ( #getqueriesforelement )
93
93
* [ Debugging] ( #debugging )
94
94
* [ ` prettyDOM ` ] ( #prettydom )
95
95
* [ Implementations] ( #implementations )
@@ -640,9 +640,9 @@ expect(submitButtons).toHaveLength(3) // expect 3 elements
640
640
expect(submitButtons[0]).toBeInTheDOM()
641
641
` ` `
642
642
643
- ## ` bindElementToQueries `
643
+ ## ` getQueriesForElement `
644
644
645
- ` bindElementToQueries ` takes a DOM element and binds it to the raw query functions , allowing them
645
+ ` getQueriesForElement ` takes a DOM element and binds it to the raw query functions , allowing them
646
646
to be used without specifying a container . It is the recommended approach for libraries built on this API
647
647
and is in use in ` react-testing-library ` and ` vue-testing-library ` .
648
648
Original file line number Diff line number Diff line change 1
- import { bindElementToQueries } from '../../bind-element-to-queries '
1
+ import { getQueriesForElement } from '../../get-queries-for-element '
2
2
3
3
function render ( html ) {
4
4
const container = document . createElement ( 'div' )
5
5
container . innerHTML = html
6
- const containerQueries = bindElementToQueries ( container )
6
+ const containerQueries = getQueriesForElement ( container )
7
7
return { container, ...containerQueries }
8
8
}
9
9
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import * as queries from './queries'
2
+
3
+ function getQueriesForElement ( element ) {
4
+ return Object . entries ( queries ) . reduce ( ( helpers , [ key , fn ] ) => {
5
+ helpers [ key ] = fn . bind ( null , element )
6
+ return helpers
7
+ } , { } )
8
+ }
9
+
10
+ export { getQueriesForElement }
Original file line number Diff line number Diff line change
1
+ import { getQueriesForElement } from './get-queries-for-element'
1
2
import * as queries from './queries'
2
3
3
4
// exporting on the queries namespace as a convenience
@@ -10,5 +11,9 @@ export * from './wait-for-element'
10
11
export * from './matches'
11
12
export * from './get-node-text'
12
13
export * from './events'
13
- export * from './bind-element-to-queries '
14
+ export * from './get-queries-for-element '
14
15
export * from './pretty-dom'
16
+
17
+ // The original name of bindElementToQueries was weird
18
+ // The new name is better. Remove this in the next major version bump.
19
+ export { getQueriesForElement as bindElementToQueries }
You can’t perform that action at this time.
0 commit comments