Fix fabric.Text#set.

This commit is contained in:
kangax 2012-09-07 13:15:42 -04:00
parent 0171b665be
commit 7cf01772a4
5 changed files with 15 additions and 21 deletions

14
dist/all.js vendored
View file

@ -13626,19 +13626,13 @@ fabric.Image.filters.Tint.fromObject = function(object) {
* @return {fabric.Text} thisArg
* @chainable
*/
set: function(name, value) {
if (typeof name == 'object') {
for (var prop in name) {
this.set(prop, name[prop]);
}
_set: function(name, value) {
if (name === 'fontFamily' && this.path) {
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
}
else {
this[name] = value;
if (name === 'fontFamily' && this.path) {
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
}
this.callSuper('_set', name, value);
}
return this;
}
});

2
dist/all.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/all.min.js.gz vendored

Binary file not shown.

View file

@ -736,19 +736,13 @@
* @return {fabric.Text} thisArg
* @chainable
*/
set: function(name, value) {
if (typeof name == 'object') {
for (var prop in name) {
this.set(prop, name[prop]);
}
_set: function(name, value) {
if (name === 'fontFamily' && this.path) {
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
}
else {
this[name] = value;
if (name === 'fontFamily' && this.path) {
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
}
this.callSuper('_set', name, value);
}
return this;
}
});

View file

@ -75,6 +75,12 @@
var text = createTextObject();
ok(typeof text.set == 'function');
equal(text.set('text', 'bar'), text, 'should be chainable');
text.set({ left: 1234, top: 2345, angle: 55 });
equal(text.get('left'), 1234);
equal(text.get('top'), 2345);
equal(text.get('angle'), 55);
});
test('set with "hash"', function() {