"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ Object.defineProperty(exports, "__esModule", { value: true }); exports.OutputNamesMigration = void 0; const migration_1 = require("../../update-tool/migration"); const angular_1 = require("../html-parsing/angular"); const upgrade_data_1 = require("../upgrade-data"); /** * Migration that walks through every inline or external HTML template and switches * changed output binding names to the proper new output name. */ class OutputNamesMigration extends migration_1.Migration { /** Change data that upgrades to the specified target version. */ data = (0, upgrade_data_1.getVersionUpgradeData)(this, 'outputNames'); // Only enable the migration rule if there is upgrade data. enabled = this.data.length !== 0; visitTemplate(template) { this.data.forEach(name => { const limitedTo = name.limitedTo; const relativeOffsets = []; if (limitedTo.attributes) { relativeOffsets.push(...(0, angular_1.findOutputsOnElementWithAttr)(template.content, name.replace, limitedTo.attributes)); } if (limitedTo.elements) { relativeOffsets.push(...(0, angular_1.findOutputsOnElementWithTag)(template.content, name.replace, limitedTo.elements)); } relativeOffsets .map(offset => template.start + offset) .forEach(start => this._replaceOutputName(template.filePath, start, name.replace.length, name.replaceWith)); }); } _replaceOutputName(filePath, start, width, newName) { this.fileSystem.edit(filePath).remove(start, width).insertRight(start, newName); } } exports.OutputNamesMigration = OutputNamesMigration; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0cHV0LW5hbWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9zY2hlbWF0aWNzL25nLXVwZGF0ZS9taWdyYXRpb25zL291dHB1dC1uYW1lcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7OztHQU1HOzs7QUFJSCwyREFBc0Q7QUFHdEQscURBQWtHO0FBQ2xHLGtEQUFtRTtBQUVuRTs7O0dBR0c7QUFDSCxNQUFhLG9CQUFxQixTQUFRLHFCQUFzQjtJQUM5RCxp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