File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ const PolylitMixinImplementation = (superclass) => {
129129 // This is run during construction of the element
130130 instance [ `_set${ upper ( name ) } ` ] = function ( value ) {
131131 setter . call ( instance , value ) ;
132+
133+ if ( options . sync ) {
134+ this . performUpdate ( ) ;
135+ }
132136 } ;
133137 } ) ;
134138
Original file line number Diff line number Diff line change @@ -925,6 +925,19 @@ describe('PolylitMixin', () => {
925925 value : 0 ,
926926 sync : true ,
927927 } ,
928+
929+ opened : {
930+ type : Boolean ,
931+ readOnly : true ,
932+ sync : true ,
933+ reflect : true ,
934+ } ,
935+
936+ helper : {
937+ type : String ,
938+ readOnly : true ,
939+ reflect : true ,
940+ } ,
928941 } ;
929942 }
930943
@@ -960,6 +973,22 @@ describe('PolylitMixin', () => {
960973 expect ( element . hasAttribute ( 'disabled' ) ) . to . be . false ;
961974 } ) ;
962975
976+ it ( 'should reflect immediately when setting a read-only sync property' , ( ) => {
977+ element . _setOpened ( true ) ;
978+ expect ( element . hasAttribute ( 'opened' ) ) . to . be . true ;
979+
980+ element . _setOpened ( false ) ;
981+ expect ( element . hasAttribute ( 'opened' ) ) . to . be . false ;
982+ } ) ;
983+
984+ it ( 'should not reflect immediately when setting a read-only non-sync property' , ( ) => {
985+ element . _setHelper ( 'foo' ) ;
986+ expect ( element . hasAttribute ( 'helper' ) ) . to . be . false ;
987+
988+ element . performUpdate ( ) ;
989+ expect ( element . hasAttribute ( 'helper' ) ) . to . be . true ;
990+ } ) ;
991+
963992 it ( 'should only call ready callback once during initialization' , ( ) => {
964993 expect ( element . count ) . to . equal ( 1 ) ;
965994 } ) ;
You can’t perform that action at this time.
0 commit comments