Comparing version 5.0.2 to 5.0.3
@@ -9,2 +9,6 @@ # Changelog | ||
## 5.0.3 | ||
* `FIX`: allow `ChangeSupport` to react to element id changes ([#19](https://github.com/bpmn-io/table-js/issues/19)) | ||
## 5.0.2 | ||
@@ -11,0 +15,0 @@ |
@@ -60,2 +60,44 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
} | ||
}, { | ||
key: 'updateId', | ||
value: function updateId(element, newId) { | ||
this._validateId(newId); | ||
if (typeof element === 'string') { | ||
element = this.get(element); | ||
} | ||
this._eventBus.fire('element.updateId', { | ||
element: element, | ||
newId: newId | ||
}); | ||
this.remove(element); | ||
element.id = newId; | ||
this.add(element); | ||
} | ||
/** | ||
* Validate the suitability of the given id and signals a problem | ||
* with an exception. | ||
* | ||
* @param {String} id | ||
* | ||
* @throws {Error} if id is empty or already assigned | ||
*/ | ||
}, { | ||
key: '_validateId', | ||
value: function _validateId(id) { | ||
if (!id) { | ||
throw new Error('element must have an id'); | ||
} | ||
if (this._elements[id]) { | ||
throw new Error('element with id ' + id + ' already added'); | ||
} | ||
} | ||
}]); | ||
@@ -62,0 +104,0 @@ |
@@ -27,8 +27,13 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
_this._listeners[newRootId] = _this._listeners[oldRootId]; | ||
delete _this._listeners[oldRootId]; | ||
_this.updateId(oldRootId, newRootId); | ||
}); | ||
} | ||
}); | ||
eventBus.on('element.updateId', function (_ref2) { | ||
var element = _ref2.element, | ||
newId = _ref2.newId; | ||
_this.updateId(element.id, newId); | ||
}); | ||
} | ||
@@ -91,2 +96,12 @@ | ||
} | ||
}, { | ||
key: 'updateId', | ||
value: function updateId(oldId, newId) { | ||
if (this._listeners[oldId]) { | ||
this._listeners[newId] = this._listeners[oldId]; | ||
delete this._listeners[oldId]; | ||
} | ||
} | ||
}]); | ||
@@ -93,0 +108,0 @@ |
{ | ||
"name": "table-js", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "all": "run-s lint test build", |
@@ -1,2 +0,2 @@ | ||
> This library exposes ES modules. Use an ES module aware transpiler such as Webpack, Rollup or Browserify + babelify to bundle it for the browser. | ||
> This library exposes [ES modules](http://exploringjs.com/es6/ch_modules.html#sec_basics-of-es6-modules). Use an ES module aware bundler such as [Webpack](https://webpack.js.org) or [Rollup](https://rollupjs.org) to bundle it for the browser. | ||
@@ -36,2 +36,2 @@ # table-js | ||
MIT | ||
MIT |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
221643
2473
37