@@ -59,10 +59,28 @@ class UI5Element extends HTMLElement {
59
59
this . _domRefReadyPromise . _deferredResolve = deferredResolve ;
60
60
61
61
this . _monitoredChildProps = new Map ( ) ;
62
- this . _firePropertyChange = false ;
62
+ this . _propertyChangeListeners = new Set ( ) ;
63
63
this . _shouldInvalidateParent = false ;
64
64
}
65
65
66
+ addEventListener ( type , listener , options ) {
67
+ if ( type === "_property-change" ) {
68
+ this . _propertyChangeListeners . add ( listener ) ;
69
+ }
70
+ return super . addEventListener ( type , listener , options ) ;
71
+ }
72
+
73
+ removeEventListener ( type , listener , options ) {
74
+ if ( type === "_property-change" ) {
75
+ this . _propertyChangeListeners . delete ( listener ) ;
76
+ }
77
+ return super . removeEventListener ( type , listener , options ) ;
78
+ }
79
+
80
+ _hasPropertyChangeListeners ( ) {
81
+ return ! ! this . _propertyChangeListeners . size ;
82
+ }
83
+
66
84
/**
67
85
* Returns a unique ID for this UI5 Element
68
86
*
@@ -394,17 +412,15 @@ class UI5Element extends HTMLElement {
394
412
* @private
395
413
*/
396
414
_attachChildPropertyUpdated ( child , listenFor ) {
397
- const childMetadata = child . constructor . getMetadata ( ) ,
398
- slotName = this . constructor . _getSlotName ( child ) , // all slotted children have the same configuration
399
- childProperties = childMetadata . getProperties ( ) ;
415
+ const slotName = this . constructor . _getSlotName ( child ) ; // all slotted children have the same configuration
400
416
401
417
let observedProps = [ ] ,
402
418
notObservedProps = [ ] ;
403
419
404
420
if ( Array . isArray ( listenFor ) ) {
405
421
observedProps = listenFor ;
406
422
} else {
407
- observedProps = Array . isArray ( listenFor . props ) ? listenFor . props : Object . keys ( childProperties ) ;
423
+ observedProps = Array . isArray ( listenFor . include ) ? listenFor . include : [ ] ;
408
424
notObservedProps = Array . isArray ( listenFor . exclude ) ? listenFor . exclude : [ ] ;
409
425
}
410
426
@@ -413,28 +429,26 @@ class UI5Element extends HTMLElement {
413
429
}
414
430
415
431
child . addEventListener ( "_property-change" , this . _invalidateParentOnPropertyUpdate ) ;
416
- child . _firePropertyChange = true ;
417
432
}
418
433
419
434
/**
420
435
* @private
421
436
*/
422
437
_detachChildPropertyUpdated ( child ) {
423
438
child . removeEventListener ( "_property-change" , this . _invalidateParentOnPropertyUpdate ) ;
424
- child . _firePropertyChange = false ;
425
439
}
426
440
427
441
/**
428
- * @private
442
+ * @private
429
443
*/
430
444
_propertyChange ( name , value ) {
431
445
this . _updateAttribute ( name , value ) ;
432
446
433
- if ( this . _firePropertyChange ) {
447
+ if ( this . _hasPropertyChangeListeners ( ) ) {
434
448
this . dispatchEvent ( new CustomEvent ( "_property-change" , {
435
449
detail : { name, newValue : value } ,
436
450
composed : false ,
437
- bubbles : true ,
451
+ bubbles : false ,
438
452
} ) ) ;
439
453
}
440
454
}
@@ -457,7 +471,10 @@ class UI5Element extends HTMLElement {
457
471
}
458
472
const { observedProps, notObservedProps } = propsMetadata ;
459
473
460
- if ( observedProps . includes ( prop . detail . name ) && ! notObservedProps . includes ( prop . detail . name ) ) {
474
+ const allPropertiesAreObserved = observedProps . length === 1 && observedProps [ 0 ] === "*" ;
475
+ const shouldObserve = allPropertiesAreObserved || observedProps . includes ( prop . detail . name ) ;
476
+ const shouldSkip = notObservedProps . includes ( prop . detail . name ) ;
477
+ if ( shouldObserve && ! shouldSkip ) {
461
478
parentNode . _invalidate ( "_parent_" , this ) ;
462
479
}
463
480
}
0 commit comments