* @param {function(boolean)} flush If `flush(false)` is invoked, mutations * that cause user-visible changes (e.g. DOM changes) will be dropped * (changes like event listener registration will be kept). * @param {number} phase * @private
(flush, phase)
| 507 | * @private |
| 508 | */ |
| 509 | mutationPump_(flush, phase) { |
| 510 | if (phase == Phase.HYDRATING) { |
| 511 | this.vsync_.mutate(() => |
| 512 | this.element.classList.add('i-amphtml-hydrated') |
| 513 | ); |
| 514 | } |
| 515 | const allowMutation = |
| 516 | this.isMutationAllowedByFixedSize() || |
| 517 | this.isMutationAllowedByUserGesture(); |
| 518 | |
| 519 | this.vsync_.mutate(() => { |
| 520 | const disallowedTypes = flush(allowMutation); |
| 521 | // Count the number of mutations dropped by type. |
| 522 | const errors = map(); |
| 523 | /** @type {!Array} */ (disallowedTypes).forEach((type) => { |
| 524 | errors[type] = errors[type] + 1 || 1; |
| 525 | }); |
| 526 | // Emit an error message for each mutation type, including count. |
| 527 | Object.keys(errors).forEach((type) => { |
| 528 | const count = errors[type]; |
| 529 | user().error(TAG, this.mutationTypeToErrorMessage_(type, count)); |
| 530 | }); |
| 531 | |
| 532 | if (disallowedTypes.length > 0 && phase === Phase.MUTATING) { |
| 533 | this.workerDom_.terminate(); |
| 534 | |
| 535 | this.element.classList.remove('i-amphtml-hydrated'); |
| 536 | this.element.classList.add('i-amphtml-broken'); |
| 537 | |
| 538 | user().error( |
| 539 | TAG, |
| 540 | '%s was terminated due to illegal mutation.', |
| 541 | this.debugId_ |
| 542 | ); |
| 543 | } |
| 544 | }); |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * @param {string} type |
nothing calls this directly
no test coverage detected