File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 86
86
getSize ( ) ;
87
87
$ ( window ) . resize ( getSize ) ;
88
88
$ ( window ) . scroll ( getSize ) ;
89
- this . $element . bind ( 'DOMNodeInserted' , getSize ) ;
89
+ if ( window . MutationObserver ) {
90
+ new MutationObserver ( getSize ) . observe ( this . $element . get ( 0 ) , {
91
+ childList : true
92
+ } ) ;
93
+ } else {
94
+ this . $element . bind ( 'DOMNodeInserted' , getSize ) ;
95
+ }
90
96
} else if ( this . options . size && this . options . size != 'auto' && menu . find ( 'li' ) . length > this . options . size ) {
91
97
var optIndex = menu . find ( "li > *" ) . filter ( ':not(.divider)' ) . slice ( 0 , this . options . size ) . last ( ) . parent ( ) . index ( ) ;
92
98
var divLength = menu . find ( "li" ) . slice ( 0 , optIndex + 1 ) . find ( '.divider' ) . length ;
93
99
menuHeight = liHeight * this . options . size + divLength * divHeight + menuPadding ;
94
100
menu . css ( { 'max-height' : menuHeight + 'px' , 'overflow-y' : 'scroll' } ) ;
95
101
}
96
102
97
- //Listen for updates to the DOM and re render...
98
- this . $element . bind ( 'DOMNodeInserted' , $ . proxy ( this . reloadLi , this ) ) ;
103
+ // Listen for updates to the DOM and re render... (Use Mutation Observer when availiable)
104
+ if ( window . MutationObserver ) {
105
+ new MutationObserver ( $ . proxy ( this . reloadLi , this ) ) . observe ( this . $element . get ( 0 ) , {
106
+ childList : true
107
+ } ) ;
108
+ } else {
109
+ this . $element . bind ( 'DOMNodeInserted' , $ . proxy ( this . reloadLi , this ) ) ;
110
+ }
99
111
100
112
this . render ( ) ;
101
113
} ,
You can’t perform that action at this time.
0 commit comments