Make isSameColor cave-insensitive. Closes #1272

This commit is contained in:
kangax 2014-04-14 12:17:06 -04:00
parent a48ed5b31b
commit d6a73aa7f5
6 changed files with 16 additions and 10 deletions

4
dist/fabric.js vendored
View file

@ -15233,9 +15233,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @return {Boolean} true if all paths are of the same color (`fill`)
*/
isSameColor: function() {
var firstPathFill = this.getObjects()[0].get('fill');
var firstPathFill = (this.getObjects()[0].get('fill') || '').toLowerCase();
return this.getObjects().every(function(path) {
return path.get('fill') === firstPathFill;
return (path.get('fill') || '').toLowerCase() === firstPathFill;
});
},

6
dist/fabric.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/fabric.min.js.gz vendored

Binary file not shown.

View file

@ -15233,9 +15233,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @return {Boolean} true if all paths are of the same color (`fill`)
*/
isSameColor: function() {
var firstPathFill = this.getObjects()[0].get('fill');
var firstPathFill = (this.getObjects()[0].get('fill') || '').toLowerCase();
return this.getObjects().every(function(path) {
return path.get('fill') === firstPathFill;
return (path.get('fill') || '').toLowerCase() === firstPathFill;
});
},

View file

@ -182,9 +182,9 @@
* @return {Boolean} true if all paths are of the same color (`fill`)
*/
isSameColor: function() {
var firstPathFill = this.getObjects()[0].get('fill');
var firstPathFill = (this.getObjects()[0].get('fill') || '').toLowerCase();
return this.getObjects().every(function(path) {
return path.get('fill') === firstPathFill;
return (path.get('fill') || '').toLowerCase() === firstPathFill;
});
},

View file

@ -66,7 +66,7 @@
function getPathGroupObject(callback) {
getPathObjects(function(objects) {
callback(new fabric.PathGroup(objects));
})
});
}
QUnit.module('fabric.PathGroup');
@ -178,6 +178,12 @@
pathGroup.getObjects()[0].set('fill', 'black');
equal(pathGroup.isSameColor(), false);
// case
pathGroup.getObjects()[0].set('fill', '#ff5555');
pathGroup.getObjects()[1].set('fill', '#FF5555');
equal(pathGroup.isSameColor(), true);
start();
});
});