File tree Expand file tree Collapse file tree 5 files changed +21
-19
lines changed Expand file tree Collapse file tree 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.
8989  *  [ TextMatch Examples] ( #textmatch-examples ) 
9090*  [ ` query `  APIs] ( #query-apis ) 
9191*  [ ` queryAll `  and ` getAll `  APIs] ( #queryall-and-getall-apis ) 
92- *  [ ` bindElementToQueries ` ] ( #bindelementtoqueries  ) 
92+ *  [ ` getQueriesForElement ` ] ( #getqueriesforelement  ) 
9393*  [ Debugging] ( #debugging ) 
9494  *  [ ` prettyDOM ` ] ( #prettydom ) 
9595*  [ Implementations] ( #implementations ) 
@@ -640,9 +640,9 @@ expect(submitButtons).toHaveLength(3) // expect 3 elements
640640expect(submitButtons[0]).toBeInTheDOM() 
641641` ` ` 
642642
643- ## ` bindElementToQueries ` 
643+ ## ` getQueriesForElement ` 
644644
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 
646646to  be  used  without  specifying  a  container . It  is  the  recommended  approach  for  libraries  built  on  this  API 
647647and  is  in  use  in  ` react-testing-library `  and  ` vue-testing-library ` .
648648
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 ' 
22
33function  render ( html )  { 
44  const  container  =  document . createElement ( 'div' ) 
55  container . innerHTML  =  html 
6-   const  containerQueries  =  bindElementToQueries ( container ) 
6+   const  containerQueries  =  getQueriesForElement ( container ) 
77  return  { container,  ...containerQueries } 
88} 
99
  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' 
12import  *  as  queries  from  './queries' 
23
34// exporting on the queries namespace as a convenience 
@@ -10,5 +11,9 @@ export * from './wait-for-element'
1011export  *  from  './matches' 
1112export  *  from  './get-node-text' 
1213export  *  from  './events' 
13- export  *  from  './bind-element-to-queries ' 
14+ export  *  from  './get-queries-for-element ' 
1415export  *  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