Test and fix current layer rename.

This commit is contained in:
Flint O'Brien
2016-05-02 18:33:45 -04:00
parent 57047b4fb1
commit 2799b4cba2
4 changed files with 61 additions and 11 deletions

View File

@@ -155,7 +155,13 @@ Layer.prototype.getTitleElement = function() {
return null;
};
Layer.prototype.setName = function(name) {
/**
* Set the name of this layer.
* @param {string} name - The new name.
* @param {svgedit.history.HistoryRecordingService} hrService - History recording service
* @returns {string|null} The new name if changed; otherwise, null.
*/
Layer.prototype.setName = function(name, hrService) {
var previousName = this.name_;
name = svgedit.utilities.toXml(name);
// now change the underlying title element contents
@@ -164,7 +170,10 @@ Layer.prototype.setName = function(name) {
while (title.firstChild) { title.removeChild(title.firstChild); }
title.textContent = name;
this.name_ = name;
return {title: title, previousName: previousName};
if( hrService) {
hrService.changeElement(title, {'#text':previousName});
}
return this.name_;
}
return null;
};