mirror of
				https://github.com/Tencent/tmagic-editor.git
				synced 2025-11-04 02:28:04 +08:00 
			
		
		
		
	fix(editor): 删除组件后,依赖清除出现可能出现大量重复循环
This commit is contained in:
		
							parent
							
								
									d79c9686e5
								
							
						
					
					
						commit
						b424abd17a
					
				@ -19,7 +19,7 @@ import { EventEmitter } from 'events';
 | 
			
		||||
 | 
			
		||||
import { reactive } from 'vue';
 | 
			
		||||
 | 
			
		||||
import { MNode } from '@tmagic/schema';
 | 
			
		||||
import { Id, MNode } from '@tmagic/schema';
 | 
			
		||||
 | 
			
		||||
type IsTarget = (key: string | number, value: any) => boolean;
 | 
			
		||||
 | 
			
		||||
@ -277,13 +277,15 @@ export class Watcher extends EventEmitter {
 | 
			
		||||
   * @param nodes 需要清除依赖的节点
 | 
			
		||||
   */
 | 
			
		||||
  public clear(nodes?: MNode[]) {
 | 
			
		||||
    const clearedItemsNodeIds: Id[] = [];
 | 
			
		||||
    Object.values(this.targets).forEach((targets) => {
 | 
			
		||||
      Object.values(targets).forEach((target) => {
 | 
			
		||||
        if (nodes) {
 | 
			
		||||
          nodes.forEach((node) => {
 | 
			
		||||
            target.removeDep(node);
 | 
			
		||||
 | 
			
		||||
            if (Array.isArray(node.items)) {
 | 
			
		||||
            if (Array.isArray(node.items) && node.items.length && !clearedItemsNodeIds.includes(node.id)) {
 | 
			
		||||
              clearedItemsNodeIds.push(node.id);
 | 
			
		||||
              this.clear(node.items);
 | 
			
		||||
            }
 | 
			
		||||
          });
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user