File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
packages/dialtone-vue/common/composables Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -259,17 +259,22 @@ export function useDOMCache(options: DOMCacheOptions = {}) {
259259
260260 nextTick ( ( ) => {
261261 if ( ! autoInvalidate ) return ;
262- const root = typeof observeRoot === 'function' ? observeRoot ( ) : observeRoot ;
263- const target = root ?? document . body ;
264- observer = new MutationObserver ( ( mutations ) => {
265- if ( shouldInvalidate ( mutations ) ) invalidate ( ) ;
266- } ) ;
267- observer . observe ( target , {
268- childList : true ,
269- subtree : true ,
270- attributes : true ,
271- attributeFilter : [ 'class' , 'id' , 'style' ] ,
272- } ) ;
262+ if ( typeof MutationObserver === 'undefined' || typeof MutationObserver . prototype === 'undefined' ) return ;
263+ try {
264+ const root = typeof observeRoot === 'function' ? observeRoot ( ) : observeRoot ;
265+ const target = root ?? document . body ;
266+ observer = new MutationObserver ( ( mutations ) => {
267+ if ( shouldInvalidate ( mutations ) ) invalidate ( ) ;
268+ } ) ;
269+ observer . observe ( target , {
270+ childList : true ,
271+ subtree : true ,
272+ attributes : true ,
273+ attributeFilter : [ 'class' , 'id' , 'style' ] ,
274+ } ) ;
275+ } catch {
276+ // MutationObserver unavailable or mocked improperly (test environments)
277+ }
273278 } ) ;
274279
275280 onUnmounted ( ( ) => { cleanup ( ) ; } ) ;
You can’t perform that action at this time.
0 commit comments