diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2019-01-13 13:11:43 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2019-01-13 13:11:43 +0100 |
commit | b1c31462b498ee50e8ed3a88b07ad4a302431d32 (patch) | |
tree | 8929bb808ffda330dddb009a9d52a40cc242f19d /src/types | |
parent | 8e4bb970c0c8772f119b5f3383b7f296ec4f2310 (diff) | |
download | svg.js-b1c31462b498ee50e8ed3a88b07ad4a302431d32.tar.gz svg.js-b1c31462b498ee50e8ed3a88b07ad4a302431d32.zip |
minor bugfix in bbox and performance changes3.0.7
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/Box.js | 17 | ||||
-rw-r--r-- | src/types/Color.js | 12 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/types/Box.js b/src/types/Box.js index 8cbda30..90979d2 100644 --- a/src/types/Box.js +++ b/src/types/Box.js @@ -7,17 +7,18 @@ import Point from './Point.js' import parser from '../modules/core/parser.js' function isNulledBox (box) { - return !box.w && !box.h && !box.x && !box.y + return !box.width && !box.height && !box.x && !box.y } function domContains (node) { - return (globals.document.documentElement.contains || function (node) { - // This is IE - it does not support contains() for top-level SVGs - while (node.parentNode) { - node = node.parentNode - } - return node === document - }).call(globals.document.documentElement, node) + return node === globals.document + || (globals.document.documentElement.contains || function (node) { + // This is IE - it does not support contains() for top-level SVGs + while (node.parentNode) { + node = node.parentNode + } + return node === globals.document + }).call(globals.document.documentElement, node) } export default class Box { diff --git a/src/types/Color.js b/src/types/Color.js index 93ca570..74f20df 100644 --- a/src/types/Color.js +++ b/src/types/Color.js @@ -423,11 +423,11 @@ export default class Color { // Test if given value is a color string static test (color) { - color += '' - return isHex.test(color) || isRgb.test(color) + return (typeof color === 'string') + && (isHex.test(color) || isRgb.test(color)) } - // Test if given value is a rgb object + // Test if given value is an rgb object static isRgb (color) { return color && typeof color.r === 'number' && typeof color.g === 'number' @@ -436,6 +436,10 @@ export default class Color { // Test if given value is a color static isColor (color) { - return this.isRgb(color) || this.test(color) + return color && ( + color instanceof Color + || this.isRgb(color) + || this.test(color) + ) } } |