mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Replace all type converting string compares with ===, !==.
This commit is contained in:
parent
115ef45464
commit
4d999d57e2
10 changed files with 24 additions and 24 deletions
6
lib/bootstrap.js
vendored
6
lib/bootstrap.js
vendored
|
@ -18,7 +18,7 @@ var Base = this.Base = new function() {
|
|||
proto = Object.prototype,
|
||||
has = fix
|
||||
? function(name) {
|
||||
return name != '__proto__' && this.hasOwnProperty(name);
|
||||
return name !== '__proto__' && this.hasOwnProperty(name);
|
||||
}
|
||||
: proto.hasOwnProperty,
|
||||
toString = proto.toString,
|
||||
|
@ -77,7 +77,7 @@ var Base = this.Base = new function() {
|
|||
function field(name, val, dontCheck, generics) {
|
||||
var val = val || (val = describe(src, name))
|
||||
&& (val.get ? val : val.value),
|
||||
func = typeof val == 'function', res = val,
|
||||
func = typeof val === 'function', res = val,
|
||||
prev = preserve || func
|
||||
? (val && val.get ? name in dest : dest[name]) : null;
|
||||
if (generics && func && (!preserve || !generics[name])) {
|
||||
|
@ -164,7 +164,7 @@ var Base = this.Base = new function() {
|
|||
function iterator(iter) {
|
||||
return !iter
|
||||
? function(val) { return val }
|
||||
: typeof iter != 'function'
|
||||
: typeof iter !== 'function'
|
||||
? function(val) { return val == iter }
|
||||
: iter;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ var Matrix = this.Matrix = Base.extend({
|
|||
* @return {Matrix} This affine transform.
|
||||
*/
|
||||
scale: function(sx, sy /* | scale */, center) {
|
||||
if (arguments.length < 2 || typeof sy == 'object') {
|
||||
if (arguments.length < 2 || typeof sy === 'object') {
|
||||
// sx is the single scale parameter, representing both sx and sy
|
||||
// Read center first from argument 1, then set sy = sx (thus
|
||||
// modifing the content of argument 1!)
|
||||
|
@ -170,7 +170,7 @@ var Matrix = this.Matrix = Base.extend({
|
|||
*/
|
||||
shear: function(shx, shy, center) {
|
||||
// See #scale() for explanation of this:
|
||||
if (arguments.length < 2 || typeof shy == 'object') {
|
||||
if (arguments.length < 2 || typeof shy === 'object') {
|
||||
center = Point.read(arguments, 1);
|
||||
sy = sx;
|
||||
} else {
|
||||
|
|
|
@ -35,7 +35,7 @@ var Element = {
|
|||
|
||||
getScrollBounds: function() {
|
||||
var doc = document.getElementsByTagName(
|
||||
document.compatMode == 'CSS1Compat' ? 'html' : 'body')[0];
|
||||
document.compatMode === 'CSS1Compat' ? 'html' : 'body')[0];
|
||||
return Rectangle.create(
|
||||
window.pageXOffset || doc.scrollLeft,
|
||||
window.pageYOffset || doc.scrollTop,
|
||||
|
|
|
@ -62,7 +62,7 @@ var Color = this.Color = Base.extend(new function() {
|
|||
|
||||
initialize: function(arg) {
|
||||
var isArray = Array.isArray(arg);
|
||||
if (typeof arg == 'object' && !isArray) {
|
||||
if (typeof arg === 'object' && !isArray) {
|
||||
if (!this._colorType) {
|
||||
// Called on the abstract Color class. Guess color type
|
||||
// from arg
|
||||
|
@ -83,7 +83,7 @@ var Color = this.Color = Base.extend(new function() {
|
|||
? color.convert(this._colorType)
|
||||
: color;
|
||||
}
|
||||
} else if (typeof arg == 'string') {
|
||||
} else if (typeof arg === 'string') {
|
||||
var rgbColor = arg.match(/^#[0-9a-f]{3,6}$/i)
|
||||
? hexToRGBColor(arg)
|
||||
: nameToRGBColor(arg);
|
||||
|
@ -112,7 +112,7 @@ var Color = this.Color = Base.extend(new function() {
|
|||
? value
|
||||
// TODO: Is this correct?
|
||||
// Shouldn't alpha be set to -1?
|
||||
: name == 'alpha' ? 1 : null;
|
||||
: name === 'alpha' ? 1 : null;
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ var Color = this.Color = Base.extend(new function() {
|
|||
for (var i = 0, l = this._components.length; i < l; i++) {
|
||||
var component = this._components[i];
|
||||
var value = this['_' + component];
|
||||
if (component == 'alpha' && value == null)
|
||||
if (component === 'alpha' && value == null)
|
||||
value = 1;
|
||||
string += (i > 0 ? ', ' : '') + component + ': ' + value;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ var Color = this.Color = Base.extend(new function() {
|
|||
|
||||
toCssString: function() {
|
||||
if (!this._cssString) {
|
||||
var color = this._colorType == 'rgb'
|
||||
var color = this._colorType === 'rgb'
|
||||
? this
|
||||
: this.convert('rgb');
|
||||
var alpha = color.getAlpha();
|
||||
|
|
|
@ -66,7 +66,7 @@ var GradientColor = this.GradientColor = Color.extend({
|
|||
|
||||
getCanvasStyle: function(ctx) {
|
||||
var gradient;
|
||||
if (this.gradient.type == 'linear') {
|
||||
if (this.gradient.type === 'linear') {
|
||||
gradient = ctx.createLinearGradient(this._origin.x, this._origin.y,
|
||||
this.destination.x, this.destination.y);
|
||||
} else {
|
||||
|
|
|
@ -613,7 +613,7 @@ var Item = this.Item = Base.extend({
|
|||
*/
|
||||
scale: function(sx, sy /* | scale */, center) {
|
||||
// See Matrix#scale for explanation of this:
|
||||
if (arguments.length < 2 || typeof sy == 'object') {
|
||||
if (arguments.length < 2 || typeof sy === 'object') {
|
||||
center = sy;
|
||||
sy = sx;
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ var Item = this.Item = Base.extend({
|
|||
shear: function(shx, shy, center) {
|
||||
// TODO: Add support for center back to Scriptographer too!
|
||||
// See Matrix#scale for explanation of this:
|
||||
if (arguments.length < 2 || typeof sy == 'object') {
|
||||
if (arguments.length < 2 || typeof sy === 'object') {
|
||||
center = shy;
|
||||
shy = shx;
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ var Item = this.Item = Base.extend({
|
|||
|
||||
// If the item has a blendMode, use BlendMode#process to
|
||||
// composite its canvas on the parentCanvas.
|
||||
if (item.blendMode != 'normal') {
|
||||
if (item.blendMode !== 'normal') {
|
||||
// The pixel offset of the temporary canvas to the parent
|
||||
// canvas.
|
||||
var pixelOffset = itemOffset.subtract(param.offset);
|
||||
|
@ -922,7 +922,7 @@ var Item = this.Item = Base.extend({
|
|||
var hash = {};
|
||||
hash[handler] = function(event) {
|
||||
// Always clear the drag set on mouse-up
|
||||
if (name == 'up')
|
||||
if (name === 'up')
|
||||
sets.drag = {};
|
||||
removeAll(sets[name]);
|
||||
sets[name] = {};
|
||||
|
@ -950,7 +950,7 @@ var Item = this.Item = Base.extend({
|
|||
sets[name][this.getId()] = this;
|
||||
// Since the drag set gets cleared in up, we need to make
|
||||
// sure it's installed too
|
||||
if (name == 'drag')
|
||||
if (name === 'drag')
|
||||
installHandler('up');
|
||||
installHandler(name);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ var Raster = this.Raster = Item.extend({
|
|||
this.setCanvas(object);
|
||||
} else {
|
||||
// If it's a string, get the element with this id first.
|
||||
if (typeof object == 'string')
|
||||
if (typeof object === 'string')
|
||||
object = document.getElementById(object);
|
||||
this.setImage(object);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ if (window.tests) {
|
|||
for (var i = 0; i < sources.length; i++) {
|
||||
document.write('<script type="text/javascript" src="' + (window.root || '')
|
||||
+ sources[i] + '"></script>');
|
||||
if (sources[i] == 'src/paper.js') {
|
||||
if (sources[i] === 'src/paper.js') {
|
||||
// Activate paper.debug for code loaded through load.js, as we're in
|
||||
// development mode.
|
||||
document.write('<script type="text/javascript">'
|
||||
|
|
|
@ -25,7 +25,7 @@ var Path = this.Path = PathItem.extend({
|
|||
// If it is an array, it can also be a description of a point, so
|
||||
// check its first entry for object as well
|
||||
this.setSegments(!segments || !Array.isArray(segments)
|
||||
|| typeof segments[0] != 'object' ? arguments : segments);
|
||||
|| typeof segments[0] !== 'object' ? arguments : segments);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -674,7 +674,7 @@ var Path = this.Path = PathItem.extend({
|
|||
// Get the start point:
|
||||
var current = getCurrentSegment(this),
|
||||
through;
|
||||
if (arguments[1] && typeof arguments[1] != 'boolean') {
|
||||
if (arguments[1] && typeof arguments[1] !== 'boolean') {
|
||||
through = Point.read(arguments, 0, 1);
|
||||
to = Point.read(arguments, 1, 1);
|
||||
} else {
|
||||
|
@ -987,7 +987,7 @@ var Path = this.Path = PathItem.extend({
|
|||
handleOut = segment.getHandleOutIfSet();
|
||||
// When both handles are set in a segment, the join setting is
|
||||
// ignored and round is always used.
|
||||
if (join == 'round' || handleIn && handleOut) {
|
||||
if (join === 'round' || handleIn && handleOut) {
|
||||
bounds = bounds.unite(joinBounds.setCenter(matrix
|
||||
? matrix.transform(segment._point) : segment._point));
|
||||
} else {
|
||||
|
@ -1033,7 +1033,7 @@ var Path = this.Path = PathItem.extend({
|
|||
normal = curve.getNormal(t).normalize(radius);
|
||||
// For square caps, we need to step away from point in the
|
||||
// direction of the tangent, which is the rotated normal
|
||||
if (cap == 'square')
|
||||
if (cap === 'square')
|
||||
point = point.add(normal.y, -normal.x);
|
||||
add(point.add(normal));
|
||||
add(point.subtract(normal));
|
||||
|
|
|
@ -29,7 +29,7 @@ var Key = new function() {
|
|||
|
||||
Event.add(document, Base.each(['keyDown', 'keyUp'], function(type) {
|
||||
var toolHandler = 'on' + Base.capitalize(type),
|
||||
keyDown = type == 'keyDown';
|
||||
keyDown = type === 'keyDown';
|
||||
this[type.toLowerCase()] = function(event) {
|
||||
var code = event.which || event.keyCode,
|
||||
key = keys[code] || String.fromCharCode(code).toLowerCase();
|
||||
|
|
Loading…
Reference in a new issue