4
4
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
*/
6
6
import { dedupeMixin } from '@open-wc/dedupe-mixin' ;
7
+ import { notEqual } from 'lit' ;
7
8
import { get , set } from './path-utils.js' ;
8
9
9
10
const caseMap = { } ;
@@ -101,12 +102,15 @@ const PolylitMixinImplementation = (superclass) => {
101
102
get : defaultDescriptor . get ,
102
103
set ( value ) {
103
104
const oldValue = this [ name ] ;
104
- this [ key ] = value ;
105
- this . requestUpdate ( name , oldValue , options ) ;
106
105
107
- // Enforce synchronous update
108
- if ( this . hasUpdated ) {
109
- this . performUpdate ( ) ;
106
+ if ( notEqual ( value , oldValue ) ) {
107
+ this [ key ] = value ;
108
+ this . requestUpdate ( name , oldValue , options ) ;
109
+
110
+ // Enforce synchronous update
111
+ if ( this . hasUpdated ) {
112
+ this . performUpdate ( ) ;
113
+ }
110
114
}
111
115
} ,
112
116
configurable : true ,
@@ -115,21 +119,17 @@ const PolylitMixinImplementation = (superclass) => {
115
119
}
116
120
117
121
if ( options . readOnly ) {
118
- const setter = defaultDescriptor . set ;
122
+ const setter = result . set ;
119
123
120
124
this . addCheckedInitializer ( ( instance ) => {
121
125
// This is run during construction of the element
122
126
instance [ `_set${ upper ( name ) } ` ] = function ( value ) {
123
127
setter . call ( instance , value ) ;
124
-
125
- if ( options . sync ) {
126
- this . performUpdate ( ) ;
127
- }
128
128
} ;
129
129
} ) ;
130
130
131
131
result = {
132
- get : defaultDescriptor . get ,
132
+ get : result . get ,
133
133
set ( ) {
134
134
// Do nothing, property is read-only.
135
135
} ,
0 commit comments