@@ -354,12 +354,13 @@ const parseDeepData = function (data, propertyPath) {
354354} ;
355355
356356class ValueStore {
357- constructor ( props ) {
358- this . identifierKey = '@id' ;
357+ constructor ( props , nestedProps ) {
359358 this . props = { } ;
359+ this . nestedProps = { } ;
360360 this . dirtyProps = { } ;
361361 this . pendingProps = { } ;
362362 this . props = props ;
363+ this . nestedProps = nestedProps ;
363364 }
364365 get ( name ) {
365366 const normalizedName = normalizeModelName ( name ) ;
@@ -369,14 +370,10 @@ class ValueStore {
369370 if ( this . pendingProps [ normalizedName ] !== undefined ) {
370371 return this . pendingProps [ normalizedName ] ;
371372 }
372- const value = getDeepData ( this . props , normalizedName ) ;
373- if ( null === value ) {
374- return value ;
373+ if ( this . nestedProps [ normalizedName ] !== undefined ) {
374+ return this . nestedProps [ normalizedName ] ;
375375 }
376- if ( this . isPropNameTopLevel ( normalizedName ) && typeof value === 'object' && value [ this . identifierKey ] !== undefined ) {
377- return value [ this . identifierKey ] ;
378- }
379- return value ;
376+ return getDeepData ( this . props , normalizedName ) ;
380377 }
381378 has ( name ) {
382379 return this . get ( name ) !== undefined ;
@@ -393,15 +390,19 @@ class ValueStore {
393390 getOriginalProps ( ) {
394391 return Object . assign ( { } , this . props ) ;
395392 }
393+ getOriginalNestedProps ( ) {
394+ return Object . assign ( { } , this . nestedProps ) ;
395+ }
396396 getDirtyProps ( ) {
397397 return Object . assign ( { } , this . dirtyProps ) ;
398398 }
399399 flushDirtyPropsToPending ( ) {
400400 this . pendingProps = Object . assign ( { } , this . dirtyProps ) ;
401401 this . dirtyProps = { } ;
402402 }
403- reinitializeAllProps ( props ) {
403+ reinitializeAllProps ( props , nestedProps ) {
404404 this . props = props ;
405+ this . nestedProps = nestedProps ;
405406 this . pendingProps = { } ;
406407 }
407408 pushPendingPropsBackToDirty ( ) {
@@ -411,24 +412,14 @@ class ValueStore {
411412 reinitializeProvidedProps ( props ) {
412413 let changed = false ;
413414 for ( const [ key , value ] of Object . entries ( props ) ) {
414- const currentIdentifier = this . get ( key ) ;
415- const newIdentifier = this . findIdentifier ( value ) ;
416- if ( currentIdentifier !== newIdentifier ) {
415+ const currentValue = this . get ( key ) ;
416+ if ( currentValue !== value ) {
417417 changed = true ;
418418 this . props [ key ] = value ;
419419 }
420420 }
421421 return changed ;
422422 }
423- isPropNameTopLevel ( key ) {
424- return key . indexOf ( '.' ) === - 1 ;
425- }
426- findIdentifier ( value ) {
427- if ( typeof value !== 'object' || value [ this . identifierKey ] === undefined ) {
428- return value ;
429- }
430- return value [ this . identifierKey ] ;
431- }
432423}
433424
434425var DOCUMENT_FRAGMENT_NODE = 11 ;
@@ -1386,7 +1377,7 @@ class ChildComponentWrapper {
13861377 }
13871378}
13881379class Component {
1389- constructor ( element , props , fingerprint , id , backend , elementDriver ) {
1380+ constructor ( element , props , nestedProps , fingerprint , id , backend , elementDriver ) {
13901381 this . defaultDebounce = 150 ;
13911382 this . backendRequest = null ;
13921383 this . pendingActions = [ ] ;
@@ -1399,7 +1390,7 @@ class Component {
13991390 this . elementDriver = elementDriver ;
14001391 this . id = id ;
14011392 this . fingerprint = fingerprint ;
1402- this . valueStore = new ValueStore ( props ) ;
1393+ this . valueStore = new ValueStore ( props , nestedProps ) ;
14031394 this . unsyncedInputsTracker = new UnsyncedInputsTracker ( this , elementDriver ) ;
14041395 this . hooks = new HookManager ( ) ;
14051396 this . resetPromise ( ) ;
@@ -1488,7 +1479,7 @@ class Component {
14881479 return children ;
14891480 }
14901481 updateFromNewElement ( toEl ) {
1491- const props = this . elementDriver . getComponentProps ( toEl ) ;
1482+ const { props } = this . elementDriver . getComponentProps ( toEl ) ;
14921483 if ( props === null ) {
14931484 return false ;
14941485 }
@@ -1590,7 +1581,8 @@ class Component {
15901581 throw error ;
15911582 }
15921583 this . hooks . triggerHook ( 'loading.state:finished' , newElement ) ;
1593- this . valueStore . reinitializeAllProps ( this . elementDriver . getComponentProps ( newElement ) ) ;
1584+ const { props : newProps , nestedProps : newNestedProps } = this . elementDriver . getComponentProps ( newElement ) ;
1585+ this . valueStore . reinitializeAllProps ( newProps , newNestedProps ) ;
15941586 executeMorphdom ( this . element , newElement , this . unsyncedInputsTracker . getUnsyncedInputs ( ) , ( element ) => getValueFromElement ( element , this . valueStore ) , Array . from ( this . getChildren ( ) . values ( ) ) , this . elementDriver . findChildComponentElement , this . elementDriver . getKeyFromElement ) ;
15951587 Object . keys ( modifiedModelValues ) . forEach ( ( modelName ) => {
15961588 this . valueStore . set ( modelName , modifiedModelValues [ modelName ] ) ;
@@ -1806,10 +1798,13 @@ class StandardElementDriver {
18061798 return modelDirective . action ;
18071799 }
18081800 getComponentProps ( rootElement ) {
1809- if ( ! rootElement . dataset . livePropsValue ) {
1810- return null ;
1811- }
1812- return JSON . parse ( rootElement . dataset . livePropsValue ) ;
1801+ var _a , _b ;
1802+ const propsJson = ( _a = rootElement . dataset . livePropsValue ) !== null && _a !== void 0 ? _a : '{}' ;
1803+ const nestedPropsJson = ( _b = rootElement . dataset . liveNestedPropsValue ) !== null && _b !== void 0 ? _b : '{}' ;
1804+ return {
1805+ props : JSON . parse ( propsJson ) ,
1806+ nestedProps : JSON . parse ( nestedPropsJson ) ,
1807+ } ;
18131808 }
18141809 findChildComponentElement ( id , element ) {
18151810 return element . querySelector ( `[data-live-id=${ id } ]` ) ;
@@ -2234,7 +2229,7 @@ class LiveControllerDefault extends Controller {
22342229 initialize ( ) {
22352230 this . handleDisconnectedChildControllerEvent = this . handleDisconnectedChildControllerEvent . bind ( this ) ;
22362231 const id = this . element . dataset . liveId || null ;
2237- this . component = new Component ( this . element , this . propsValue , this . fingerprintValue , id , new Backend ( this . urlValue , this . csrfValue ) , new StandardElementDriver ( ) ) ;
2232+ this . component = new Component ( this . element , this . propsValue , this . nestedPropsValue , this . fingerprintValue , id , new Backend ( this . urlValue , this . csrfValue ) , new StandardElementDriver ( ) ) ;
22382233 this . proxiedComponent = proxifyComponent ( this . component ) ;
22392234 this . element . __component = this . proxiedComponent ;
22402235 if ( this . hasDebounceValue ) {
@@ -2393,6 +2388,7 @@ class LiveControllerDefault extends Controller {
23932388LiveControllerDefault . values = {
23942389 url : String ,
23952390 props : Object ,
2391+ nestedProps : { type : Object , default : { } } ,
23962392 csrf : String ,
23972393 debounce : { type : Number , default : 150 } ,
23982394 id : String ,
0 commit comments