From 0578c6c644d8f6ad415686e62f71782880035c4c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 22 Jan 2015 15:05:49 -0600 Subject: [PATCH] Use strict equality --- index.js | 4 ++-- lib/get-all-background-image-declarations.js | 7 ++++--- lib/get-meta-info-for-declaration.js | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 5ff0eee..fab3b17 100644 --- a/index.js +++ b/index.js @@ -85,8 +85,8 @@ var spriter = function(options) { // Filter out any declartion with the `include: false` meta chunkBackgroundImageDeclarations = chunkBackgroundImageDeclarations.filter(function(declaration) { var metaIncludeValue = (declaration.meta && declaration.meta.spritesheet && declaration.meta.spritesheet.include); - var shouldIncludeBecauseImplicit = settings.includeMode == 'implicit' && (metaIncludeValue === undefined || metaIncludeValue); - var shouldIncludeBecauseExplicit = settings.includeMode == 'explicit' && metaIncludeValue; + var shouldIncludeBecauseImplicit = settings.includeMode === 'implicit' && (metaIncludeValue === undefined || metaIncludeValue); + var shouldIncludeBecauseExplicit = settings.includeMode === 'explicit' && metaIncludeValue; var shouldInclude = shouldIncludeBecauseImplicit || shouldIncludeBecauseExplicit; // Only return declartions that shouldn't be skipped diff --git a/lib/get-all-background-image-declarations.js b/lib/get-all-background-image-declarations.js index e54d8f8..d618a8a 100644 --- a/lib/get-all-background-image-declarations.js +++ b/lib/get-all-background-image-declarations.js @@ -11,14 +11,14 @@ function getAllBackgroundImageDeclarations(styles) { // Get all the declarations that have background `url()` declarations var backgroundImageDeclarations = []; styles.stylesheet.rules.forEach(function(rule) { - if(rule.type == 'rule') { + if(rule.type === 'rule') { rule.declarations.forEach(function(declaration, declarationIndex) { // background-image always has a url - if(declaration.property == 'background-image') { + if(declaration.property === 'background-image') { backgroundImageDeclarations.push(attachInfoToDeclaration(rule, declarationIndex)); } // Background is a shorthand property so make sure `url()` is in there - else if(declaration.property == 'background') { + else if(declaration.property === 'background') { var hasImageValue = spriterUtil.backgroundURLRegex.test(declaration.value); if(hasImageValue) { @@ -42,6 +42,7 @@ function attachInfoToDeclaration(rule, declarationIndex) var declarationMetaInfo = getMetaInfoForDeclaration(rule, declarationIndex); // Add the meta into to the declaration + // Check for null or undefined if(declaration.meta == null) { declaration.meta = {}; } diff --git a/lib/get-meta-info-for-declaration.js b/lib/get-meta-info-for-declaration.js index 280c484..994bdcc 100644 --- a/lib/get-meta-info-for-declaration.js +++ b/lib/get-meta-info-for-declaration.js @@ -30,7 +30,7 @@ function getMetaInfoForDeclaration(rule, declarationIndex) { //console.log(afterDeclaration); //console.log(afterDeclaration.position.start.line, mainDeclaration.position.start.line); // Make sure that the comment starts on the same line as the main declaration - if(afterDeclaration.position.start.line == mainDeclaration.position.start.line) { + if(afterDeclaration.position.start.line === mainDeclaration.position.start.line) { extend(resultantMetaData, parseCommentDecarationForMeta(afterDeclaration)); } } @@ -39,7 +39,7 @@ function getMetaInfoForDeclaration(rule, declarationIndex) { function parseCommentDecarationForMeta(declaration) { - if(declaration.type == "comment") + if(declaration.type === "comment") { //console.log(declaration);