chore(Viewer+Modeler): consistently name private instance variables
BREAKING CHANGE: * definitions, container and moddle have been prefixed with an underscore (_) to denote they are private use.
This commit is contained in:
parent
844bc9a922
commit
642d7b88af
|
@ -112,7 +112,7 @@ function Modeler(options) {
|
|||
}, this);
|
||||
|
||||
this.on('diagram.destroy', function() {
|
||||
this.moddle.ids.clear();
|
||||
this.get('moddle').ids.clear();
|
||||
}, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,17 +107,17 @@ function Viewer(options) {
|
|||
|
||||
options = assign({}, DEFAULT_OPTIONS, options);
|
||||
|
||||
this.moddle = this._createModdle(options);
|
||||
this._moddle = this._createModdle(options);
|
||||
|
||||
this.container = this._createContainer(options);
|
||||
this._container = this._createContainer(options);
|
||||
|
||||
/* <project-logo> */
|
||||
|
||||
addProjectLogo(this.container);
|
||||
addProjectLogo(this._container);
|
||||
|
||||
/* </project-logo> */
|
||||
|
||||
this._init(this.container, this.moddle, options);
|
||||
this._init(this._container, this._moddle, options);
|
||||
}
|
||||
|
||||
inherits(Viewer, Diagram);
|
||||
|
@ -157,7 +157,7 @@ Viewer.prototype.importXML = function(xml, done) {
|
|||
// allow xml manipulation
|
||||
xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
||||
|
||||
this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
|
||||
this._moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
|
||||
|
||||
// hook in post parse listeners +
|
||||
// allow definitions manipulation
|
||||
|
@ -204,13 +204,13 @@ Viewer.prototype.saveXML = function(options, done) {
|
|||
options = {};
|
||||
}
|
||||
|
||||
var definitions = this.definitions;
|
||||
var definitions = this._definitions;
|
||||
|
||||
if (!definitions) {
|
||||
return done(new Error('no definitions loaded'));
|
||||
}
|
||||
|
||||
this.moddle.toXML(definitions, options, done);
|
||||
this._moddle.toXML(definitions, options, done);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -296,13 +296,13 @@ Viewer.prototype.importDefinitions = function(definitions, done) {
|
|||
// that may be raised during model parsing
|
||||
try {
|
||||
|
||||
if (this.definitions) {
|
||||
if (this._definitions) {
|
||||
// clear existing rendered diagram
|
||||
this.clear();
|
||||
}
|
||||
|
||||
// update definitions
|
||||
this.definitions = definitions;
|
||||
this._definitions = definitions;
|
||||
|
||||
// perform graphical import
|
||||
Importer.importBpmnDiagram(this, definitions, done);
|
||||
|
@ -327,7 +327,7 @@ Viewer.prototype.destroy = function() {
|
|||
Diagram.prototype.destroy.call(this);
|
||||
|
||||
// dom detach
|
||||
domRemove(this.container);
|
||||
domRemove(this._container);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -373,9 +373,7 @@ Viewer.prototype.attachTo = function(parentNode) {
|
|||
parentNode = domQuery(parentNode);
|
||||
}
|
||||
|
||||
var container = this._container;
|
||||
|
||||
parentNode.appendChild(container);
|
||||
parentNode.appendChild(this._container);
|
||||
|
||||
this._emit('attach', {});
|
||||
};
|
||||
|
@ -396,7 +394,6 @@ Viewer.prototype.detach = function() {
|
|||
|
||||
Viewer.prototype._init = function(container, moddle, options) {
|
||||
|
||||
this._container = container;
|
||||
var baseModules = options.modules || this.getModules(),
|
||||
additionalModules = options.additionalModules || [],
|
||||
staticModules = [
|
||||
|
|
|
@ -433,7 +433,7 @@ describe('Viewer', function() {
|
|||
return done(err);
|
||||
}
|
||||
|
||||
var svgDoc = viewer.container.childNodes[1].childNodes[1];
|
||||
var svgDoc = viewer._container.childNodes[1].childNodes[1];
|
||||
|
||||
|
||||
|
||||
|
@ -524,9 +524,9 @@ describe('Viewer', function() {
|
|||
});
|
||||
|
||||
// then
|
||||
expect(viewer.container.style.position).to.equal('fixed');
|
||||
expect(viewer.container.style.width).to.equal('200px');
|
||||
expect(viewer.container.style.height).to.equal('100px');
|
||||
expect(viewer._container.style.position).to.equal('fixed');
|
||||
expect(viewer._container.style.width).to.equal('200px');
|
||||
expect(viewer._container.style.height).to.equal('100px');
|
||||
});
|
||||
|
||||
|
||||
|
@ -739,7 +739,7 @@ describe('Viewer', function() {
|
|||
|
||||
viewer.importXML(xml, function(err, warnings) {
|
||||
|
||||
expect(viewer.container.parentNode).to.equal(container);
|
||||
expect(viewer._container.parentNode).to.equal(container);
|
||||
|
||||
done(err, warnings);
|
||||
});
|
||||
|
@ -753,7 +753,7 @@ describe('Viewer', function() {
|
|||
|
||||
viewer.importXML(xml, function(err, warnings) {
|
||||
|
||||
expect(viewer.container.parentNode).to.equal(null);
|
||||
expect(viewer._container.parentNode).to.equal(null);
|
||||
|
||||
done(err, warnings);
|
||||
});
|
||||
|
@ -929,7 +929,7 @@ describe('Viewer', function() {
|
|||
viewer.destroy();
|
||||
|
||||
// then
|
||||
expect(viewer.container.parentNode).not.to.exist;
|
||||
expect(viewer._container.parentNode).not.to.exist;
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -944,9 +944,9 @@ describe('Viewer', function() {
|
|||
|
||||
viewer.importXML(xml, function(err, warnings) {
|
||||
|
||||
expect(viewer.container.parentNode).to.equal(null);
|
||||
expect(viewer._container.parentNode).to.equal(null);
|
||||
viewer.attachTo(container);
|
||||
expect(viewer.container.parentNode).to.equal(container);
|
||||
expect(viewer._container.parentNode).to.equal(container);
|
||||
|
||||
done(err, warnings);
|
||||
});
|
||||
|
@ -963,9 +963,9 @@ describe('Viewer', function() {
|
|||
|
||||
viewer.importXML(xml, function(err, warnings) {
|
||||
|
||||
expect(viewer.container.parentNode).to.equal(container);
|
||||
expect(viewer._container.parentNode).to.equal(container);
|
||||
viewer.detach();
|
||||
expect(viewer.container.parentNode).to.equal(null);
|
||||
expect(viewer._container.parentNode).to.equal(null);
|
||||
|
||||
done(err, warnings);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue