File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed
js/__internal/core/widget
testing/tests/DevExpress.core Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -142,9 +142,18 @@ class DOMComponent<
142142
143143 // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
144144 _setOptionsByDevice ( instanceCustomRules ) : void {
145- // @ts -expect-error
146- // eslint-disable-next-line @stylistic/max-len
147- super . _setOptionsByDevice ( [ ] . concat ( this . constructor . _classCustomRules || [ ] , instanceCustomRules || [ ] ) ) ;
145+ const ctor = this . constructor ;
146+
147+ const hasOwnCustomRules = Object . prototype . hasOwnProperty . call ( ctor , '_classCustomRules' ) ;
148+ const hasOwnDefaultOptions = Object . prototype . hasOwnProperty . call ( ctor , 'defaultOptions' ) ;
149+
150+ const ownClassCustomRules = hasOwnCustomRules
151+ || hasOwnDefaultOptions
152+ // @ts -expect-error
153+ ? ctor . _classCustomRules
154+ : [ ] ;
155+
156+ super . _setOptionsByDevice ( [ ] . concat ( ownClassCustomRules || [ ] , instanceCustomRules || [ ] ) ) ;
148157 }
149158
150159 _isInitialOptionValue ( name : string ) : boolean {
Original file line number Diff line number Diff line change @@ -652,6 +652,36 @@ QUnit.module('default', {
652652 assert . equal ( new TestComponent1 ( $ ( '<div/>' ) ) . option ( 'anotherOption' ) , 'Another option value' , 'Multiple calls should not clean previous rules' ) ;
653653 } ) ;
654654
655+ QUnit . test ( 'should not be inherited by child class/component (T1286533)' , function ( assert ) {
656+ const TestComponent1 = DOMComponent . inherit ( {
657+ _getDefaultOptions ( ) {
658+ return $ . extend ( this . callBase ( ) , {
659+ test : 'test1'
660+ } ) ;
661+ } ,
662+ } ) ;
663+
664+ const TestComponent2 = TestComponent1 . inherit ( {
665+ _getDefaultOptions ( ) {
666+ return $ . extend ( this . callBase ( ) , {
667+ test : 'test2'
668+ } ) ;
669+ } ,
670+ } ) ;
671+
672+ registerComponent ( 'TestComponent1' , TestComponent1 ) ;
673+ registerComponent ( 'TestComponent2' , TestComponent2 ) ;
674+
675+ TestComponent1 . defaultOptions ( {
676+ options : {
677+ notInherited : 'notInherited' ,
678+ }
679+ } ) ;
680+
681+ assert . equal ( new TestComponent1 ( $ ( '<div>' ) ) . option ( 'notInherited' ) , 'notInherited' ) ;
682+ assert . equal ( new TestComponent2 ( $ ( '<div>' ) ) . option ( 'notInherited' ) , undefined ) ;
683+ } ) ;
684+
655685 QUnit . test ( 'DevExpress.rtlEnabled proxied to DOMComponent' , function ( assert ) {
656686 assert . equal ( config ( ) . rtlEnabled , false , 'DevExpress.rtlEnabled equals false by default' ) ;
657687 assert . equal ( new DOMComponent ( $ ( '<div/>' ) ) . option ( 'rtlEnabled' ) , false , 'false by default' ) ;
You can’t perform that action at this time.
0 commit comments