Prevent redefinition of class libraries
A number of classes used in PolyGerrit are defined in vanilla JS files that are included multiple times by various elements. For example, gr-diff-line.js is included by the gr-diff-builder and by gr-diff elements. Adds #ifndef-style guards to each of these libraries to prevent redefinition and avoid different elements potentially referring to different versions of the same class. Change-Id: I45e3ba425a59989b328475b1fe58fd9f350c8ae0
This commit is contained in:
parent
ea65e9bff1
commit
16810999f6
|
@ -14,6 +14,9 @@
|
|||
(function(window, GrDiffBuilderSideBySide) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffBuilderImage) { return; }
|
||||
|
||||
function GrDiffBuilderImage(diff, comments, prefs, outputEl, baseImage,
|
||||
revisionImage) {
|
||||
GrDiffBuilderSideBySide.call(this, diff, comments, prefs, outputEl);
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
(function(window, GrDiffBuilder) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffBuilderSideBySide) { return; }
|
||||
|
||||
function GrDiffBuilderSideBySide(diff, comments, prefs, outputEl) {
|
||||
GrDiffBuilder.call(this, diff, comments, prefs, outputEl);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
(function(window, GrDiffBuilder) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffBuilderUnified) { return; }
|
||||
|
||||
function GrDiffBuilderUnified(diff, comments, prefs, outputEl) {
|
||||
GrDiffBuilder.call(this, diff, comments, prefs, outputEl);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
(function(window, GrDiffGroup, GrDiffLine) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffBuilder) { return; }
|
||||
|
||||
function GrDiffBuilder(diff, comments, prefs, outputEl) {
|
||||
this._diff = diff;
|
||||
this._comments = comments;
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
(function(window, GrDiffLine) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffGroup) { return; }
|
||||
|
||||
function GrDiffGroup(type, opt_lines) {
|
||||
this.type = type;
|
||||
this.lines = [];
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
(function(window) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffLine) { return; }
|
||||
|
||||
function GrDiffLine(type) {
|
||||
this.type = type;
|
||||
this.highlights = [];
|
||||
|
|
Loading…
Reference in New Issue