|
371 | 371 | */ |
372 | 372 | function runComputedEffects(inst, changedProps, oldProps, hasPaths) { |
373 | 373 | let computeEffects = inst.__computeEffects; |
374 | | - if (computeEffects) { |
375 | | - let inputProps = changedProps; |
376 | | - while (runEffects(inst, computeEffects, inputProps, oldProps, hasPaths)) { |
| 374 | + let inputProps = changedProps; |
| 375 | + while (inputProps) { |
| 376 | + computeEffects && runEffects(inst, computeEffects, inputProps, oldProps, hasPaths); |
| 377 | + computeLinkedPaths(inst, inputProps, hasPaths); |
| 378 | + if ((inputProps = inst.__dataPending)) { |
377 | 379 | Object.assign(oldProps, inst.__dataOld); |
378 | 380 | Object.assign(changedProps, inst.__dataPending); |
379 | | - inputProps = inst.__dataPending; |
380 | 381 | inst.__dataPending = null; |
381 | 382 | } |
382 | 383 | } |
|
416 | 417 | function computeLinkedPaths(inst, changedProps, hasPaths) { |
417 | 418 | let links; |
418 | 419 | if (hasPaths && (links = inst.__dataLinkedPaths)) { |
419 | | - const cache = inst.__dataTemp; |
420 | 420 | let link; |
421 | 421 | for (let a in links) { |
422 | 422 | let b = links[a]; |
423 | 423 | for (let path in changedProps) { |
424 | 424 | if (Polymer.Path.isDescendant(a, path)) { |
425 | 425 | link = Polymer.Path.translate(a, b, path); |
426 | | - cache[link] = changedProps[link] = changedProps[path]; |
427 | | - let notifyProps = inst.__dataToNotify || (inst.__dataToNotify = {}); |
428 | | - notifyProps[link] = true; |
| 426 | + inst._setPendingPropertyOrPath(link, changedProps[path], true, true); |
429 | 427 | } else if (Polymer.Path.isDescendant(b, path)) { |
430 | 428 | link = Polymer.Path.translate(b, a, path); |
431 | | - cache[link] = changedProps[link] = changedProps[path]; |
432 | | - let notifyProps = inst.__dataToNotify || (inst.__dataToNotify = {}); |
433 | | - notifyProps[link] = true; |
| 429 | + inst._setPendingPropertyOrPath(link, changedProps[path], true, true); |
434 | 430 | } |
435 | 431 | } |
436 | 432 | } |
|
1292 | 1288 | */ |
1293 | 1289 | _setPendingPropertyOrPath(path, value, shouldNotify, isPathNotification) { |
1294 | 1290 | let rootProperty = Polymer.Path.root(Array.isArray(path) ? path[0] : path); |
1295 | | - let hasAccessor = this.__dataHasAccessor && this.__dataHasAccessor[rootProperty]; |
1296 | | - let isPath = (rootProperty !== path); |
1297 | | - if (hasAccessor) { |
1298 | | - if (isPath) { |
1299 | | - if (!isPathNotification) { |
1300 | | - // Dirty check changes being set to a path against the actual object, |
1301 | | - // since this is the entry point for paths into the system; from here |
1302 | | - // the only dirty checks are against the `__dataTemp` cache to prevent |
1303 | | - // duplicate work in the same turn only. Note, if this was a notification |
1304 | | - // of a change already set to a path (isPathNotification: true), |
1305 | | - // we always let the change through and skip the `set` since it was |
1306 | | - // already dirty checked at the point of entry and the underlying |
1307 | | - // object has already been updated |
1308 | | - let old = Polymer.Path.get(this, path); |
1309 | | - path = /** @type {string} */ (Polymer.Path.set(this, path, value)); |
1310 | | - // Use property-accessor's simpler dirty check |
1311 | | - if (!path || !super._shouldPropertyChange(path, value, old)) { |
1312 | | - return false; |
1313 | | - } |
| 1291 | + if (rootProperty !== path) { |
| 1292 | + if (!isPathNotification) { |
| 1293 | + // Dirty check changes being set to a path against the actual object, |
| 1294 | + // since this is the entry point for paths into the system; from here |
| 1295 | + // the only dirty checks are against the `__dataTemp` cache to prevent |
| 1296 | + // duplicate work in the same turn only. Note, if this was a notification |
| 1297 | + // of a change already set to a path (isPathNotification: true), |
| 1298 | + // we always let the change through and skip the `set` since it was |
| 1299 | + // already dirty checked at the point of entry and the underlying |
| 1300 | + // object has already been updated |
| 1301 | + let old = Polymer.Path.get(this, path); |
| 1302 | + path = /** @type {string} */ (Polymer.Path.set(this, path, value)); |
| 1303 | + // Use property-accessor's simpler dirty check |
| 1304 | + if (!path || !super._shouldPropertyChange(path, value, old)) { |
| 1305 | + return false; |
1314 | 1306 | } |
1315 | | - this.__dataHasPaths = true; |
1316 | 1307 | } |
| 1308 | + this.__dataHasPaths = true; |
1317 | 1309 | return this._setPendingProperty(path, value, shouldNotify); |
1318 | 1310 | } else { |
1319 | | - if (isPath) { |
1320 | | - Polymer.Path.set(this, path, value); |
| 1311 | + if (this.__dataHasAccessor && this.__dataHasAccessor[rootProperty]) { |
| 1312 | + return this._setPendingProperty(path, value, shouldNotify); |
1321 | 1313 | } else { |
1322 | 1314 | this[path] = value; |
1323 | 1315 | } |
|
1548 | 1540 | this.__dataHasPaths = false; |
1549 | 1541 | // Compute properties |
1550 | 1542 | runComputedEffects(this, changedProps, oldProps, hasPaths); |
1551 | | - // Compute linked paths |
1552 | | - computeLinkedPaths(this, changedProps, hasPaths); |
1553 | 1543 | // Clear notify properties prior to possible reentry (propagate, observe), |
1554 | 1544 | // but after computing effects have a chance to add to them |
1555 | 1545 | let notifyProps = this.__dataToNotify; |
|
0 commit comments