Merge branch 'NilSet-path-cache-invalidation'
This commit is contained in:
		
						commit
						65c4d40a87
					
				@ -275,11 +275,10 @@ const cleanupTransactions = (transactionCleanups, i) => {
 | 
				
			|||||||
      )
 | 
					      )
 | 
				
			||||||
      fs.push(() => {
 | 
					      fs.push(() => {
 | 
				
			||||||
        // deep observe events
 | 
					        // deep observe events
 | 
				
			||||||
        transaction.changedParentTypes.forEach((events, type) =>
 | 
					        transaction.changedParentTypes.forEach((events, type) => {
 | 
				
			||||||
          fs.push(() => {
 | 
					 | 
				
			||||||
          // We need to think about the possibility that the user transforms the
 | 
					          // We need to think about the possibility that the user transforms the
 | 
				
			||||||
          // Y.Doc in the event.
 | 
					          // Y.Doc in the event.
 | 
				
			||||||
            if (type._item === null || !type._item.deleted) {
 | 
					          if (type._dEH.l.length > 0 && (type._item === null || !type._item.deleted)) {
 | 
				
			||||||
            events = events
 | 
					            events = events
 | 
				
			||||||
              .filter(event =>
 | 
					              .filter(event =>
 | 
				
			||||||
                event.target._item === null || !event.target._item.deleted
 | 
					                event.target._item === null || !event.target._item.deleted
 | 
				
			||||||
@ -287,6 +286,8 @@ const cleanupTransactions = (transactionCleanups, i) => {
 | 
				
			|||||||
            events
 | 
					            events
 | 
				
			||||||
              .forEach(event => {
 | 
					              .forEach(event => {
 | 
				
			||||||
                event.currentTarget = type
 | 
					                event.currentTarget = type
 | 
				
			||||||
 | 
					                // path is relative to the current target
 | 
				
			||||||
 | 
					                event._path = null
 | 
				
			||||||
              })
 | 
					              })
 | 
				
			||||||
            // sort events by path length so that top-level events are fired first.
 | 
					            // sort events by path length so that top-level events are fired first.
 | 
				
			||||||
            events
 | 
					            events
 | 
				
			||||||
@ -296,9 +297,8 @@ const cleanupTransactions = (transactionCleanups, i) => {
 | 
				
			|||||||
            callEventHandlerListeners(type._dEH, events, transaction)
 | 
					            callEventHandlerListeners(type._dEH, events, transaction)
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
        fs.push(() => doc.emit('afterTransaction', [transaction, doc]))
 | 
					 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
 | 
					      fs.push(() => doc.emit('afterTransaction', [transaction, doc]))
 | 
				
			||||||
      callAll(fs, [])
 | 
					      callAll(fs, [])
 | 
				
			||||||
      if (transaction._needFormattingCleanup) {
 | 
					      if (transaction._needFormattingCleanup) {
 | 
				
			||||||
        cleanupYTextAfterTransaction(transaction)
 | 
					        cleanupYTextAfterTransaction(transaction)
 | 
				
			||||||
 | 
				
			|||||||
@ -337,6 +337,34 @@ export const testObserversUsingObservedeep = tc => {
 | 
				
			|||||||
  compare(users)
 | 
					  compare(users)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @param {t.TestCase} tc
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export const testPathsOfSiblingEvents = tc => {
 | 
				
			||||||
 | 
					  const { users, map0 } = init(tc, { users: 2 })
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @type {Array<Array<string|number>>}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  const pathes = []
 | 
				
			||||||
 | 
					  let calls = 0
 | 
				
			||||||
 | 
					  const doc = users[0]
 | 
				
			||||||
 | 
					  map0.set('map', new Y.Map())
 | 
				
			||||||
 | 
					  map0.get('map').set('text1', new Y.Text('initial'))
 | 
				
			||||||
 | 
					  map0.observeDeep(events => {
 | 
				
			||||||
 | 
					    events.forEach(event => {
 | 
				
			||||||
 | 
					      pathes.push(event.path)
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					    calls++
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  doc.transact(() => {
 | 
				
			||||||
 | 
					    map0.get('map').get('text1').insert(0, 'post-')
 | 
				
			||||||
 | 
					    map0.get('map').set('text2', new Y.Text('new'))
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  t.assert(calls === 1)
 | 
				
			||||||
 | 
					  t.compare(pathes, [['map'], ['map', 'text1']])
 | 
				
			||||||
 | 
					  compare(users)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: Test events in Y.Map
 | 
					// TODO: Test events in Y.Map
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @param {Object<string,any>} is
 | 
					 * @param {Object<string,any>} is
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user