Comparing version 1.0.3 to 1.0.4
27
index.js
@@ -5,2 +5,3 @@ /* global __dirname */ | ||
var glob = require('glob'); | ||
var type = require('./lib/oftype.js'); | ||
@@ -20,10 +21,10 @@ function jsPattern (path) { | ||
var conditions = [ | ||
!type(c,'object'), | ||
!type(s,'array'), | ||
!type(c,Object), | ||
!type(s,Array), | ||
!s.length, | ||
s.some(i => !type(i,'object')), | ||
s.some(i => type(i.src,'undefined')), | ||
s.some(i => type(i.tag,'undefined')), | ||
s.some(i => (!type(i.src,'string') || !/.\.(html|htm)$/.test(i.src))), | ||
s.some(i => !type(i.tag,'string')), | ||
s.some(i => !type(i,Object)), | ||
s.some(i => type(i.src,undefined)), | ||
s.some(i => type(i.tag,undefined)), | ||
s.some(i => (!type(i.src,String) || !/.\.(html|htm)$/.test(i.src))), | ||
s.some(i => !type(i.tag,String)), | ||
s.some(i => !i.tag.length), | ||
@@ -61,2 +62,3 @@ s.some(i => !/[A-Za-z_$][A-Za-z0-9_$]*/.test(i.tag)), | ||
files.unshift(jsPattern(path.join(__dirname, '/lib/appender.js'))); | ||
files.unshift(jsPattern(path.join(__dirname, '/lib/oftype.js'))); | ||
files.unshift(cssPattern(path.join(__dirname, '/lib/styles.css'))); | ||
@@ -73,10 +75,2 @@ }; | ||
function type(value,type){ | ||
type = type.toLowerCase(); | ||
if(typeof value==='undefined'&&type==='undefined') return true; | ||
if(value===null&&type==='null') return true; | ||
if(value===null||value===undefined) return false; | ||
return value.constructor.toString().toLowerCase().search(type)>=0; | ||
} | ||
function hasDoubles(a){ | ||
@@ -97,3 +91,2 @@ for(var x=0;x<a.length;x++){ | ||
'reporter:karmaHTML': ['factory',loadHTML] | ||
}; | ||
}; |
@@ -33,3 +33,3 @@ function KarmaHTML(){ | ||
open: function(o){ | ||
if(utils.type(o,'object')){ | ||
if(ofType(o,'object')){ | ||
this.width = o.width; | ||
@@ -145,9 +145,2 @@ this.height = o.height; | ||
var utils = { | ||
type: function(value,type){ | ||
type = type.toLowerCase(); | ||
if(typeof value==='undefined'&&type==='undefined') return true; | ||
if(value===null&&type==='null') return true; | ||
if(value===null||value===undefined) return false; | ||
return value.constructor.toString().toLowerCase().search(type)>=0; | ||
}, | ||
findPath: function(path){ | ||
@@ -232,22 +225,21 @@ var files = Object.getOwnPropertyNames(window.__karma__.files); | ||
function validData(name,value){ | ||
var type = utils.type; | ||
if(type(value,'undefined')) return false; | ||
if(ofType(value,'undefined')) return false; | ||
switch(name) { | ||
case "source": | ||
return ((type(value,'string')&&value!=='') || (type(value,'array'))); | ||
return ((ofType(value,'string')&&value!=='') || (ofType(value,'array'))); | ||
break; | ||
case "timeout": | ||
return (type(value,'number')&&value>=0); | ||
return (ofType(value,'number')&&value>=0); | ||
break; | ||
case "abort": | ||
return (type(value,'number')&&value>=0); | ||
return (ofType(value,'number')&&value>=0); | ||
break; | ||
case "width": | ||
return (type(value,'string')) && validCSS('width',value); | ||
return (ofType(value,'string')) && validCSS('width',value); | ||
break; | ||
case "height": | ||
return (type(value,'string')) && validCSS('height',value); | ||
return (ofType(value,'string')) && validCSS('height',value); | ||
break; | ||
case "auto": | ||
return (type(value,'boolean')); | ||
return (ofType(value,'boolean')); | ||
break; | ||
@@ -282,6 +274,6 @@ default: | ||
function callOnLoad(response,status,textStatus){ | ||
if(utils.type(this.onstatechange,'function')){ | ||
if(ofType(this.onstatechange,'function')){ | ||
this.onstatechange.call(this,response,this.tag,status,textStatus); | ||
} | ||
if(utils.type(this._root.onstatechange,'function')){ | ||
if(ofType(this._root.onstatechange,'function')){ | ||
this._root.onstatechange.call(this._root,response,this.tag,status,textStatus); | ||
@@ -333,5 +325,5 @@ } | ||
var elem = this._root.elementList[this.itemNum][el]; | ||
if(utils.type(value,'null')){ | ||
if(ofType(value,'null')){ | ||
elem.style[prop] = this._root.config[prop]; | ||
} else if (utils.type(value,'string')&&validCSS(prop,value)){ | ||
} else if (ofType(value,'string')&&validCSS(prop,value)){ | ||
elem.style[prop] = value; | ||
@@ -338,0 +330,0 @@ } |
{ | ||
"name": "karma-html", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Load html files and test the DOM in the browser", | ||
@@ -29,2 +29,2 @@ "main": "index.js", | ||
"homepage": "https://github.com/devrafalko/karma-html#readme" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
51751
8
539