@@ -2622,7 +2622,7 @@ function wrapError(fn, hookName) {
2622
2622
result . catch ( ( ) => { } ) ,
2623
2623
new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( TIMEOUT ) , 3000 ) ) ,
2624
2624
] ) . then ( ( res ) => {
2625
- if ( res === TIMEOUT && node . fiber === fiber ) {
2625
+ if ( res === TIMEOUT && node . fiber === fiber && node . status <= 2 ) {
2626
2626
console . warn ( timeoutError ) ;
2627
2627
}
2628
2628
} ) ;
@@ -3512,7 +3512,7 @@ function compileExprToArray(expr) {
3512
3512
const localVars = new Set ( ) ;
3513
3513
const tokens = tokenize ( expr ) ;
3514
3514
let i = 0 ;
3515
- let stack = [ ] ; // to track last opening [ or {
3515
+ let stack = [ ] ; // to track last opening (, [ or {
3516
3516
while ( i < tokens . length ) {
3517
3517
let token = tokens [ i ] ;
3518
3518
let prevToken = tokens [ i - 1 ] ;
@@ -3521,10 +3521,12 @@ function compileExprToArray(expr) {
3521
3521
switch ( token . type ) {
3522
3522
case "LEFT_BRACE" :
3523
3523
case "LEFT_BRACKET" :
3524
+ case "LEFT_PAREN" :
3524
3525
stack . push ( token . type ) ;
3525
3526
break ;
3526
3527
case "RIGHT_BRACE" :
3527
3528
case "RIGHT_BRACKET" :
3529
+ case "RIGHT_PAREN" :
3528
3530
stack . pop ( ) ;
3529
3531
}
3530
3532
let isVar = token . type === "SYMBOL" && ! RESERVED_WORDS . includes ( token . value ) ;
@@ -3636,6 +3638,13 @@ function isProp(tag, key) {
3636
3638
}
3637
3639
return false ;
3638
3640
}
3641
+ /**
3642
+ * Returns a template literal that evaluates to str. You can add interpolation
3643
+ * sigils into the string if required
3644
+ */
3645
+ function toStringExpression ( str ) {
3646
+ return `\`${ str . replace ( / \\ / g, "\\\\" ) . replace ( / ` / g, "\\`" ) . replace ( / \$ \{ / , "\\${" ) } \`` ;
3647
+ }
3639
3648
// -----------------------------------------------------------------------------
3640
3649
// BlockDescription
3641
3650
// -----------------------------------------------------------------------------
@@ -3816,15 +3825,14 @@ class CodeGenerator {
3816
3825
mainCode . push ( `` ) ;
3817
3826
for ( let block of this . blocks ) {
3818
3827
if ( block . dom ) {
3819
- let xmlString = block . asXmlString ( ) ;
3820
- xmlString = xmlString . replace ( / \\ / g, "\\\\" ) . replace ( / ` / g, "\\`" ) ;
3828
+ let xmlString = toStringExpression ( block . asXmlString ( ) ) ;
3821
3829
if ( block . dynamicTagName ) {
3822
- xmlString = xmlString . replace ( / ^ < \w + / , `<\${tag || '${ block . dom . nodeName } '}` ) ;
3823
- xmlString = xmlString . replace ( / \w + > $ / , `\${tag || '${ block . dom . nodeName } '}>` ) ;
3824
- mainCode . push ( `let ${ block . blockName } = tag => createBlock(\` ${ xmlString } \` );` ) ;
3830
+ xmlString = xmlString . replace ( / ^ ` < \w + / , `\ `<\${tag || '${ block . dom . nodeName } '}`) ;
3831
+ xmlString = xmlString . replace ( / \w + > ` $ / , `\${tag || '${ block . dom . nodeName } '}>\` ` ) ;
3832
+ mainCode . push ( `let ${ block . blockName } = tag => createBlock(${ xmlString } );` ) ;
3825
3833
}
3826
3834
else {
3827
- mainCode . push ( `let ${ block . blockName } = createBlock(\` ${ xmlString } \` );` ) ;
3835
+ mainCode . push ( `let ${ block . blockName } = createBlock(${ xmlString } );` ) ;
3828
3836
}
3829
3837
}
3830
3838
}
@@ -4002,7 +4010,7 @@ class CodeGenerator {
4002
4010
const isNewBlock = ! block || forceNewBlock ;
4003
4011
if ( isNewBlock ) {
4004
4012
block = this . createBlock ( block , "comment" , ctx ) ;
4005
- this . insertBlock ( `comment(\` ${ ast . value } \` )` , block , {
4013
+ this . insertBlock ( `comment(${ toStringExpression ( ast . value ) } )` , block , {
4006
4014
...ctx ,
4007
4015
forceNewBlock : forceNewBlock && ! block ,
4008
4016
} ) ;
@@ -4024,7 +4032,7 @@ class CodeGenerator {
4024
4032
}
4025
4033
if ( ! block || forceNewBlock ) {
4026
4034
block = this . createBlock ( block , "text" , ctx ) ;
4027
- this . insertBlock ( `text(\` ${ value } \` )` , block , {
4035
+ this . insertBlock ( `text(${ toStringExpression ( value ) } )` , block , {
4028
4036
...ctx ,
4029
4037
forceNewBlock : forceNewBlock && ! block ,
4030
4038
} ) ;
@@ -4245,7 +4253,8 @@ class CodeGenerator {
4245
4253
expr = compileExpr ( ast . expr ) ;
4246
4254
if ( ast . defaultValue ) {
4247
4255
this . helpers . add ( "withDefault" ) ;
4248
- expr = `withDefault(${ expr } , \`${ ast . defaultValue } \`)` ;
4256
+ // FIXME: defaultValue is not translated
4257
+ expr = `withDefault(${ expr } , ${ toStringExpression ( ast . defaultValue ) } )` ;
4249
4258
}
4250
4259
}
4251
4260
if ( ! block || forceNewBlock ) {
@@ -4498,7 +4507,7 @@ class CodeGenerator {
4498
4507
this . addLine ( `${ ctxVar } [zero] = ${ bl } ;` ) ;
4499
4508
}
4500
4509
}
4501
- const key = `key + \` ${ this . generateComponentKey ( ) } \`` ;
4510
+ const key = this . generateComponentKey ( ) ;
4502
4511
if ( isDynamic ) {
4503
4512
const templateVar = generateId ( "template" ) ;
4504
4513
if ( ! this . staticDefs . find ( ( d ) => d . id === "call" ) ) {
@@ -4550,12 +4559,12 @@ class CodeGenerator {
4550
4559
else {
4551
4560
let value ;
4552
4561
if ( ast . defaultValue ) {
4553
- const defaultValue = ctx . translate ? this . translate ( ast . defaultValue ) : ast . defaultValue ;
4562
+ const defaultValue = toStringExpression ( ctx . translate ? this . translate ( ast . defaultValue ) : ast . defaultValue ) ;
4554
4563
if ( ast . value ) {
4555
- value = `withDefault(${ expr } , \` ${ defaultValue } \` )` ;
4564
+ value = `withDefault(${ expr } , ${ defaultValue } )` ;
4556
4565
}
4557
4566
else {
4558
- value = `\` ${ defaultValue } \`` ;
4567
+ value = defaultValue ;
4559
4568
}
4560
4569
}
4561
4570
else {
@@ -4566,12 +4575,12 @@ class CodeGenerator {
4566
4575
}
4567
4576
return null ;
4568
4577
}
4569
- generateComponentKey ( ) {
4578
+ generateComponentKey ( currentKey = "key" ) {
4570
4579
const parts = [ generateId ( "__" ) ] ;
4571
4580
for ( let i = 0 ; i < this . target . loopLevel ; i ++ ) {
4572
4581
parts . push ( `\${key${ i + 1 } }` ) ;
4573
4582
}
4574
- return parts . join ( "__" ) ;
4583
+ return ` ${ currentKey } + \` ${ parts . join ( "__" ) } \`` ;
4575
4584
}
4576
4585
/**
4577
4586
* Formats a prop name and value into a string suitable to be inserted in the
@@ -4662,7 +4671,6 @@ class CodeGenerator {
4662
4671
this . addLine ( `${ propVar } .slots = markRaw(Object.assign(${ slotDef } , ${ propVar } .slots))` ) ;
4663
4672
}
4664
4673
// cmap key
4665
- const key = this . generateComponentKey ( ) ;
4666
4674
let expr ;
4667
4675
if ( ast . isDynamic ) {
4668
4676
expr = generateId ( "Comp" ) ;
@@ -4678,7 +4686,7 @@ class CodeGenerator {
4678
4686
// todo: check the forcenewblock condition
4679
4687
this . insertAnchor ( block ) ;
4680
4688
}
4681
- let keyArg = `key + \` ${ key } \`` ;
4689
+ let keyArg = this . generateComponentKey ( ) ;
4682
4690
if ( ctx . tKeyExpr ) {
4683
4691
keyArg = `${ ctx . tKeyExpr } + ${ keyArg } ` ;
4684
4692
}
@@ -4751,7 +4759,7 @@ class CodeGenerator {
4751
4759
}
4752
4760
let key = this . target . loopLevel ? `key${ this . target . loopLevel } ` : "key" ;
4753
4761
if ( isMultiple ) {
4754
- key = ` ${ key } + \` ${ this . generateComponentKey ( ) } \`` ;
4762
+ key = this . generateComponentKey ( key ) ;
4755
4763
}
4756
4764
const props = ast . attrs ? this . formatPropObject ( ast . attrs ) : [ ] ;
4757
4765
const scope = this . getPropString ( props , dynProps ) ;
@@ -4792,7 +4800,6 @@ class CodeGenerator {
4792
4800
}
4793
4801
let { block } = ctx ;
4794
4802
const name = this . compileInNewTarget ( "slot" , ast . content , ctx ) ;
4795
- const key = this . generateComponentKey ( ) ;
4796
4803
let ctxStr = "ctx" ;
4797
4804
if ( this . target . loopLevel || ! this . hasSafeContext ) {
4798
4805
ctxStr = generateId ( "ctx" ) ;
@@ -4805,7 +4812,8 @@ class CodeGenerator {
4805
4812
expr : `app.createComponent(null, false, true, false, false)` ,
4806
4813
} ) ;
4807
4814
const target = compileExpr ( ast . target ) ;
4808
- const blockString = `${ id } ({target: ${ target } ,slots: {'default': {__render: ${ name } .bind(this), __ctx: ${ ctxStr } }}}, key + \`${ key } \`, node, ctx, Portal)` ;
4815
+ const key = this . generateComponentKey ( ) ;
4816
+ const blockString = `${ id } ({target: ${ target } ,slots: {'default': {__render: ${ name } .bind(this), __ctx: ${ ctxStr } }}}, ${ key } , node, ctx, Portal)` ;
4809
4817
if ( block ) {
4810
4818
this . insertAnchor ( block ) ;
4811
4819
}
@@ -5538,7 +5546,7 @@ function compile(template, options = {}) {
5538
5546
}
5539
5547
5540
5548
// do not modify manually. This file is generated by the release script.
5541
- const version = "2.2.10 " ;
5549
+ const version = "2.2.11 " ;
5542
5550
5543
5551
// -----------------------------------------------------------------------------
5544
5552
// Scheduler
@@ -5964,9 +5972,9 @@ TemplateSet.prototype._compileTemplate = function _compileTemplate(name, templat
5964
5972
} ) ;
5965
5973
} ;
5966
5974
5967
- export { App , Component , EventBus , OwlError , __info__ , blockDom , loadFile , markRaw , markup , mount , onError , onMounted , onPatched , onRendered , onWillDestroy , onWillPatch , onWillRender , onWillStart , onWillUnmount , onWillUpdateProps , reactive , status , toRaw , useChildSubEnv , useComponent , useEffect , useEnv , useExternalListener , useRef , useState , useSubEnv , validate , validateType , whenReady , xml } ;
5975
+ export { App , Component , EventBus , OwlError , __info__ , batched , blockDom , loadFile , markRaw , markup , mount , onError , onMounted , onPatched , onRendered , onWillDestroy , onWillPatch , onWillRender , onWillStart , onWillUnmount , onWillUpdateProps , reactive , status , toRaw , useChildSubEnv , useComponent , useEffect , useEnv , useExternalListener , useRef , useState , useSubEnv , validate , validateType , whenReady , xml } ;
5968
5976
5969
5977
5970
- __info__ . date = '2024-04-02T10:25:32.577Z ' ;
5971
- __info__ . hash = '97b69f1 ' ;
5978
+ __info__ . date = '2024-06-17T13:31:12.099Z ' ;
5979
+ __info__ . hash = 'e7f405c ' ;
5972
5980
__info__ . url = 'https://github.com/odoo/owl' ;
0 commit comments