Get rid of global GrDiffBuilderSideBySide
* Replace the global GrDiffBuilderSideBySide variable with named imports. * Update gr-app-global-var-init.js Change-Id: I11d2480a2709d0037c255cf885b2375c2e7e1dbf
This commit is contained in:
@@ -179,7 +179,6 @@ module.exports = {
|
||||
"GrCountStringFormatter": "readonly",
|
||||
"GrDiffBuilderBinary": "readonly",
|
||||
"GrDiffBuilderImage": "readonly",
|
||||
"GrDiffBuilderSideBySide": "readonly",
|
||||
"GrDiffBuilderUnified": "readonly",
|
||||
"GrDomHook": "readonly",
|
||||
"GrDomHooksManager": "readonly",
|
||||
|
||||
@@ -32,6 +32,7 @@ import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-diff-builder-element_html.js';
|
||||
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation.js';
|
||||
import {GrDiffBuilder} from './gr-diff-builder.js';
|
||||
import {GrDiffBuilderSideBySide} from './gr-diff-builder-side-by-side.js';
|
||||
|
||||
const DiffViewMode = {
|
||||
SIDE_BY_SIDE: 'SIDE_BY_SIDE',
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function(window, GrDiffBuilderSideBySide) {
|
||||
|
||||
import {GrDiffBuilderSideBySide} from './gr-diff-builder-side-by-side.js';
|
||||
|
||||
(function(window) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
@@ -180,4 +183,4 @@
|
||||
};
|
||||
|
||||
window.GrDiffBuilderImage = GrDiffBuilderImage;
|
||||
})(window, GrDiffBuilderSideBySide);
|
||||
})(window);
|
||||
|
||||
@@ -17,20 +17,14 @@
|
||||
|
||||
import {GrDiffBuilder} from './gr-diff-builder.js';
|
||||
|
||||
(function(window) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffBuilderSideBySide) { return; }
|
||||
|
||||
/** @constructor */
|
||||
function GrDiffBuilderSideBySide(diff, prefs, outputEl, layers) {
|
||||
/** @constructor */
|
||||
export function GrDiffBuilderSideBySide(diff, prefs, outputEl, layers) {
|
||||
GrDiffBuilder.call(this, diff, prefs, outputEl, layers);
|
||||
}
|
||||
GrDiffBuilderSideBySide.prototype = Object.create(GrDiffBuilder.prototype);
|
||||
GrDiffBuilderSideBySide.prototype.constructor = GrDiffBuilderSideBySide;
|
||||
}
|
||||
GrDiffBuilderSideBySide.prototype = Object.create(GrDiffBuilder.prototype);
|
||||
GrDiffBuilderSideBySide.prototype.constructor = GrDiffBuilderSideBySide;
|
||||
|
||||
GrDiffBuilderSideBySide.prototype.buildSectionElement = function(group) {
|
||||
GrDiffBuilderSideBySide.prototype.buildSectionElement = function(group) {
|
||||
const sectionEl = this._createElement('tbody', 'section');
|
||||
sectionEl.classList.add(group.type);
|
||||
if (this._isTotal(group)) {
|
||||
@@ -48,9 +42,9 @@ import {GrDiffBuilder} from './gr-diff-builder.js';
|
||||
pairs[i].right));
|
||||
}
|
||||
return sectionEl;
|
||||
};
|
||||
};
|
||||
|
||||
GrDiffBuilderSideBySide.prototype.addColumns = function(outputEl, fontSize) {
|
||||
GrDiffBuilderSideBySide.prototype.addColumns = function(outputEl, fontSize) {
|
||||
const width = fontSize * 4;
|
||||
const colgroup = document.createElement('colgroup');
|
||||
|
||||
@@ -75,9 +69,9 @@ import {GrDiffBuilder} from './gr-diff-builder.js';
|
||||
colgroup.appendChild(document.createElement('col'));
|
||||
|
||||
outputEl.appendChild(colgroup);
|
||||
};
|
||||
};
|
||||
|
||||
GrDiffBuilderSideBySide.prototype._createRow = function(section, leftLine,
|
||||
GrDiffBuilderSideBySide.prototype._createRow = function(section, leftLine,
|
||||
rightLine) {
|
||||
const row = this._createElement('tr');
|
||||
row.classList.add('diff-row', 'side-by-side');
|
||||
@@ -92,9 +86,9 @@ import {GrDiffBuilder} from './gr-diff-builder.js';
|
||||
this._appendPair(section, row, rightLine, rightLine.afterNumber,
|
||||
GrDiffBuilder.Side.RIGHT);
|
||||
return row;
|
||||
};
|
||||
};
|
||||
|
||||
GrDiffBuilderSideBySide.prototype._appendPair = function(section, row, line,
|
||||
GrDiffBuilderSideBySide.prototype._appendPair = function(section, row, line,
|
||||
lineNumber, side) {
|
||||
const lineNumberEl = this._createLineEl(line, lineNumber, line.type, side);
|
||||
row.appendChild(lineNumberEl);
|
||||
@@ -105,9 +99,9 @@ import {GrDiffBuilder} from './gr-diff-builder.js';
|
||||
const textEl = this._createTextEl(lineNumberEl, line, side);
|
||||
row.appendChild(textEl);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
GrDiffBuilderSideBySide.prototype._getNextContentOnSide = function(
|
||||
GrDiffBuilderSideBySide.prototype._getNextContentOnSide = function(
|
||||
content, side) {
|
||||
let tr = content.parentElement.parentElement;
|
||||
while (tr = tr.nextSibling) {
|
||||
@@ -116,7 +110,4 @@ import {GrDiffBuilder} from './gr-diff-builder.js';
|
||||
if (content) { return content; }
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
window.GrDiffBuilderSideBySide = GrDiffBuilderSideBySide;
|
||||
})(window);
|
||||
};
|
||||
|
||||
@@ -28,6 +28,7 @@ import {GrAttributeHelper} from './plugins/gr-attribute-helper/gr-attribute-help
|
||||
import {GrDiffLine} from './diff/gr-diff/gr-diff-line.js';
|
||||
import {GrDiffGroup} from './diff/gr-diff/gr-diff-group.js';
|
||||
import {GrDiffBuilder} from './diff/gr-diff-builder/gr-diff-builder.js';
|
||||
import {GrDiffBuilderSideBySide} from './diff/gr-diff-builder/gr-diff-builder-side-by-side.js';
|
||||
|
||||
export function initGlobalVariables() {
|
||||
window.GrDisplayNameUtils = GrDisplayNameUtils;
|
||||
@@ -36,4 +37,5 @@ export function initGlobalVariables() {
|
||||
window.GrDiffLine = GrDiffLine;
|
||||
window.GrDiffGroup = GrDiffGroup;
|
||||
window.GrDiffBuilder = GrDiffBuilder;
|
||||
window.GrDiffBuilderSideBySide = GrDiffBuilderSideBySide;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user