File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11import  "regenerator-runtime/runtime" ;  // needed for ``await`` support 
22import  Base  from  "../../core/base" ; 
33import  Parser  from  "../../core/parser" ; 
4+ import  dom  from  "../../core/dom" ; 
45import  logging  from  "../../core/logging" ; 
56
67// Lazy loading modules. 
@@ -27,7 +28,7 @@ export default Base.extend({
2728
2829        this . options  =  parser . parse ( this . el ,  this . options ) ; 
2930
30-         let  lang  =  this . options . locale  ||  document . querySelector ( "html" ) . lang  ||  "en" ; 
31+         let  lang  =  this . options . locale  ||  dom . acquire_attribute ( this . el ,   "lang" )  ||  "en" ; 
3132        // we don't support any country-specific language variants, always use first 2 letters 
3233        lang  =  lang . substr ( 0 ,  2 ) . toLowerCase ( ) ; 
3334        try  { 
Original file line number Diff line number Diff line change @@ -59,6 +59,24 @@ describe("pat-display-time tests", () => {
5959        expect ( el . textContent ) . toBe ( "April Donnerstag 22. 2021, 4:00:00" ) ; 
6060    } ) ; 
6161
62+     it ( "Example setting the output format in German due containment in German container" ,  async  ( )  =>  { 
63+         document . body . innerHTML  =  ` 
64+           <section lang="de"> 
65+               <time 
66+                   class="pat-display-time" 
67+                   datetime="2021-04-22T23:00Z" 
68+                   data-pat-display-time="output-format: MMMM dddd Do YYYY, h:mm:ss"> 
69+               </time> 
70+           </section> 
71+         ` ; 
72+         const  el  =  document . querySelector ( ".pat-display-time" ) ; 
73+ 
74+         Pattern . init ( el ) ; 
75+         await  utils . timeout ( 1 ) ;  // wait a tick for async to settle. 
76+ 
77+         expect ( el . textContent ) . toBe ( "April Donnerstag 22. 2021, 4:00:00" ) ; 
78+     } ) ; 
79+ 
6280    it ( "Output formatted as local" ,  async  ( )  =>  { 
6381        document . body . innerHTML  =  ` 
6482          <time 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments