jquery.onoff
Advanced tools
+3
-3
| { | ||
| "name": "onoff", | ||
| "version": "0.2.4", | ||
| "version": "0.3.0", | ||
| "ignore": [ | ||
@@ -14,7 +14,7 @@ "**/.*", | ||
| "devDependencies": { | ||
| "qunit": "~1.12.0", | ||
| "qunit": "~1.14.0", | ||
| "jquery": "~1.10.0", | ||
| "requirejs": "~2.1.10", | ||
| "jquery.event.pointertouch": "~0.0.5" | ||
| "jquery.event.pointertouch": "~0.1.0" | ||
| } | ||
| } |
+37
-37
@@ -1,2 +0,2 @@ | ||
| /** onoff - v0.2.4 - 2014-03-03 | ||
| /** jquery.onoff - v0.3.0 - 2014-03-03 | ||
| * https://github.com/timmywil/jquery.onoff | ||
@@ -19,46 +19,46 @@ * Copyright (c) 2014 Timmy Willison; Licensed MIT */ | ||
| // Common properties to lift for touch or pointer events | ||
| var props = [ 'pageX', 'pageY', 'clientX', 'clientY' ]; | ||
| var hook = { props: props }; | ||
| var hook = $.event.mouseHooks; | ||
| var props = hook.props; | ||
| var events = {}; | ||
| var list = 'over out down up move enter leave cancel'.split(' '); | ||
| var touchReplace = { down: 'start', up: 'end' }; | ||
| // Support pointer events in IE11+ if available | ||
| if ( window.PointerEvent ) { | ||
| $.each([ 'pointerdown', 'pointermove', 'pointerup' ], function( i, name ) { | ||
| // Add event name to events property | ||
| events[ name.replace('pointer', '') ] = name; | ||
| $.each(list, function( i, name ) { | ||
| // Add event name to events property and add fixHook | ||
| $.event.fixHooks[ | ||
| (events[name] = 'pointer' + name) | ||
| ] = hook; | ||
| }); | ||
| } else { | ||
| // Add touches property for the touch hook | ||
| props.push('touches', 'changedTouches', 'targetTouches', 'altKey', 'ctrlKey', 'metaKey', 'shiftKey'); | ||
| /** | ||
| * Support: Android | ||
| * Android sets pageX/Y to 0 for any touch event | ||
| * Attach first touch's pageX/pageY and clientX/clientY if not set correctly | ||
| */ | ||
| hook.filter = function( event, originalEvent ) { | ||
| var touch; | ||
| if ( !originalEvent.pageX && originalEvent.touches && (touch = originalEvent.touches[0]) ) { | ||
| event.pageX = touch.pageX; | ||
| event.pageY = touch.pageY; | ||
| event.clientX = touch.clientX; | ||
| event.clientY = touch.clientY; | ||
| } | ||
| return event; | ||
| }; | ||
| // Take off 'over' and 'out' when attaching touch hooks | ||
| $.each(list.slice(2), function( i, name ) { | ||
| var touch = 'touch' + (touchReplace[name] || name); | ||
| // Add fixHook | ||
| $.event.fixHooks[ name ] = hook; | ||
| $.event.fixHooks[ touch ] = hook; | ||
| // Add event names to events property | ||
| events[ name ] = touch + ' mouse' + name; | ||
| }); | ||
| } | ||
| // Add touches property for the touch hook | ||
| props.push('touches'); | ||
| /** | ||
| * Support: Android | ||
| * Android sets pageX/Y to 0 for any touch event | ||
| * Attach first touch's pageX/pageY and clientX/clientY if not set correctly | ||
| */ | ||
| hook.filter = function( event, originalEvent ) { | ||
| var touch; | ||
| if ( !originalEvent.pageX && originalEvent.touches && (touch = originalEvent.touches[0]) ) { | ||
| event.pageX = touch.pageX; | ||
| event.pageY = touch.pageY; | ||
| event.clientX = touch.clientX; | ||
| event.clientY = touch.clientY; | ||
| } | ||
| return event; | ||
| }; | ||
| $.each({ | ||
| mousedown: 'touchstart', | ||
| mousemove: 'touchmove', | ||
| mouseup: 'touchend' | ||
| }, function( mouse, touch ) { | ||
| // Add event names to events property | ||
| events[ mouse.replace('mouse', '') ] = mouse + ' ' + touch; | ||
| // Add fixHook | ||
| $.event.fixHooks[ touch ] = hook; | ||
| }); | ||
| $.pointertouch = events; | ||
@@ -65,0 +65,0 @@ |
@@ -1,4 +0,4 @@ | ||
| /** onoff - v0.2.4 - 2014-03-03 | ||
| /** jquery.onoff - v0.3.0 - 2014-03-03 | ||
| * https://github.com/timmywil/jquery.onoff | ||
| * Copyright (c) 2014 Timmy Willison; Licensed MIT */ | ||
| !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?b(require("jquery")):b(a.jQuery)}(this,function(a){"use strict";function b(c,d){if(!(this instanceof b))return new b(c,d);if("input"!==c.nodeName.toLowerCase()||"checkbox"!==c.type)return a.error("OnOff should be called on checkboxes");var e=a.data(c,b.datakey);return e?e:(this.options=d=a.extend({},b.defaults,d),this.elem=c,this.$elem=a(c).addClass(d.className),this.$doc=a(c.ownerDocument||document),d.namespace+=a.guid++,c.id||(c.id="onoffswitch"+f++),this.enable(),a.data(c,b.datakey,this),void 0)}var c=["pageX","pageY","clientX","clientY"],d={props:c},e={};window.PointerEvent&&a.each(["pointerdown","pointermove","pointerup"],function(b,c){e[c.replace("pointer","")]=c,a.event.fixHooks[c]=d}),c.push("touches"),d.filter=function(a,b){var c;return!b.pageX&&b.touches&&(c=b.touches[0])&&(a.pageX=c.pageX,a.pageY=c.pageY,a.clientX=c.clientX,a.clientY=c.clientY),a},a.each({mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},function(b,c){e[b.replace("mouse","")]=b+" "+c,a.event.fixHooks[c]=d}),a.pointertouch=e;var f=1,g=Array.prototype.slice;return b.datakey="_onoff",b.defaults={namespace:".onoff",className:"onoffswitch-checkbox"},b.prototype={constructor:b,instance:function(){return this},wrap:function(){var b=this.elem,c=this.$elem,d=c.parent(".onoffswitch");d.length||(c.wrap('<div class="onoffswitch"></div>'),d=c.parent()),this.$con=d;var e=c.next('label[for="'+b.id+'"]');e.length||(e=a("<label/>").attr("for",b.id).insertAfter(b)),this.$label=e.addClass("onoffswitch-label");var f=e.find(".onoffswitch-inner");f.length||(f=a("<div/>").addClass("onoffswitch-inner").prependTo(e)),this.$inner=f;var g=e.find(".onoffswitch-switch");g.length||(g=a("<div/>").addClass("onoffswitch-switch").appendTo(e)),this.$switch=g},_handleMove:function(a){if(!this.disabled){this.moved=!0,this.lastX=a.clientX;var b=Math.max(Math.min(this.startX-this.lastX,this.maxRight),0);this.$switch.css("right",b),this.$inner.css("marginLeft",100*-(b/this.maxRight)+"%")}},_startMove:function(b){b.preventDefault();var c,d;"pointerdown"===b.type?(c="pointermove",d="pointerup"):"touchstart"===b.type?(c="touchmove",d="touchend"):(c="mousemove",d="mouseup");var e=this.elem,f=this.options.namespace,g=this.$switch,h=g[0],i=this.$inner.add(g).css("transition","none");this.maxRight=this.$con.width()-g.width()-a.css(h,"margin-left",!0)-a.css(h,"margin-right",!0)-a.css(h,"border-left-width",!0)-a.css(h,"border-right-width",!0);var j=e.checked;this.moved=!1,this.startX=b.clientX+(j?0:this.maxRight);var k=this,l=this.$doc.on(c+f,a.proxy(this._handleMove,this)).on(d+f,function(){i.css("transition",""),l.off(f),setTimeout(function(){k.moved&&(e.checked=k.lastX>k.startX-k.maxRight/2),k.$switch.css("right",""),k.$inner.css("marginLeft","")})})},_bind:function(){this._unbind(),this.$switch.on(a.pointertouch.down,a.proxy(this._startMove,this))},enable:function(){this.wrap(),this._bind(),this.disabled=!1},_unbind:function(){this.$doc.add(this.$switch).off(this.options.namespace)},disable:function(){this.disabled=!0,this._unbind()},unwrap:function(){this.disable(),this.$label.remove(),this.$elem.unwrap()},isDisabled:function(){return this.disabled},destroy:function(){this.disable(),a.removeData(this.elem,b.datakey)},option:function(b,c){var d,e=this.options;if(!b)return a.extend({},e);if("string"==typeof b){if(1===arguments.length)return void 0!==e[b]?e[b]:null;d={},d[b]=c}else d=b;a.each(d,a.proxy(function(a,b){switch(a){case"namespace":this._unbind();break;case"className":this.$elem.removeClass(e.className)}switch(e[a]=b,a){case"namespace":this._bind();break;case"className":this.$elem.addClass(b)}},this))}},a.fn.onoff=function(c){var d,e,f,h;return"string"==typeof c?(h=[],e=g.call(arguments,1),this.each(function(){d=a.data(this,b.datakey),d?"_"!==c.charAt(0)&&"function"==typeof(f=d[c])&&void 0!==(f=f.apply(d,e))&&h.push(f):h.push(void 0)}),h.length?1===h.length?h[0]:h:this):this.each(function(){new b(this,c)})},a.OnOff=b}); | ||
| !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?b(require("jquery")):b(a.jQuery)}(this,function(a){"use strict";function b(c,d){if(!(this instanceof b))return new b(c,d);if("input"!==c.nodeName.toLowerCase()||"checkbox"!==c.type)return a.error("OnOff should be called on checkboxes");var e=a.data(c,b.datakey);return e?e:(this.options=d=a.extend({},b.defaults,d),this.elem=c,this.$elem=a(c).addClass(d.className),this.$doc=a(c.ownerDocument||document),d.namespace+=a.guid++,c.id||(c.id="onoffswitch"+h++),this.enable(),a.data(c,b.datakey,this),void 0)}var c=a.event.mouseHooks,d=c.props,e={},f="over out down up move enter leave cancel".split(" "),g={down:"start",up:"end"};window.PointerEvent?a.each(f,function(b,d){a.event.fixHooks[e[d]="pointer"+d]=c}):(d.push("touches","changedTouches","targetTouches","altKey","ctrlKey","metaKey","shiftKey"),c.filter=function(a,b){var c;return!b.pageX&&b.touches&&(c=b.touches[0])&&(a.pageX=c.pageX,a.pageY=c.pageY,a.clientX=c.clientX,a.clientY=c.clientY),a},a.each(f.slice(2),function(b,d){var f="touch"+(g[d]||d);a.event.fixHooks[f]=c,e[d]=f+" mouse"+d})),a.pointertouch=e;var h=1,i=Array.prototype.slice;return b.datakey="_onoff",b.defaults={namespace:".onoff",className:"onoffswitch-checkbox"},b.prototype={constructor:b,instance:function(){return this},wrap:function(){var b=this.elem,c=this.$elem,d=c.parent(".onoffswitch");d.length||(c.wrap('<div class="onoffswitch"></div>'),d=c.parent()),this.$con=d;var e=c.next('label[for="'+b.id+'"]');e.length||(e=a("<label/>").attr("for",b.id).insertAfter(b)),this.$label=e.addClass("onoffswitch-label");var f=e.find(".onoffswitch-inner");f.length||(f=a("<div/>").addClass("onoffswitch-inner").prependTo(e)),this.$inner=f;var g=e.find(".onoffswitch-switch");g.length||(g=a("<div/>").addClass("onoffswitch-switch").appendTo(e)),this.$switch=g},_handleMove:function(a){if(!this.disabled){this.moved=!0,this.lastX=a.clientX;var b=Math.max(Math.min(this.startX-this.lastX,this.maxRight),0);this.$switch.css("right",b),this.$inner.css("marginLeft",100*-(b/this.maxRight)+"%")}},_startMove:function(b){b.preventDefault();var c,d;"pointerdown"===b.type?(c="pointermove",d="pointerup"):"touchstart"===b.type?(c="touchmove",d="touchend"):(c="mousemove",d="mouseup");var e=this.elem,f=this.options.namespace,g=this.$switch,h=g[0],i=this.$inner.add(g).css("transition","none");this.maxRight=this.$con.width()-g.width()-a.css(h,"margin-left",!0)-a.css(h,"margin-right",!0)-a.css(h,"border-left-width",!0)-a.css(h,"border-right-width",!0);var j=e.checked;this.moved=!1,this.startX=b.clientX+(j?0:this.maxRight);var k=this,l=this.$doc.on(c+f,a.proxy(this._handleMove,this)).on(d+f,function(){i.css("transition",""),l.off(f),setTimeout(function(){k.moved&&(e.checked=k.lastX>k.startX-k.maxRight/2),k.$switch.css("right",""),k.$inner.css("marginLeft","")})})},_bind:function(){this._unbind(),this.$switch.on(a.pointertouch.down,a.proxy(this._startMove,this))},enable:function(){this.wrap(),this._bind(),this.disabled=!1},_unbind:function(){this.$doc.add(this.$switch).off(this.options.namespace)},disable:function(){this.disabled=!0,this._unbind()},unwrap:function(){this.disable(),this.$label.remove(),this.$elem.unwrap()},isDisabled:function(){return this.disabled},destroy:function(){this.disable(),a.removeData(this.elem,b.datakey)},option:function(b,c){var d,e=this.options;if(!b)return a.extend({},e);if("string"==typeof b){if(1===arguments.length)return void 0!==e[b]?e[b]:null;d={},d[b]=c}else d=b;a.each(d,a.proxy(function(a,b){switch(a){case"namespace":this._unbind();break;case"className":this.$elem.removeClass(e.className)}switch(e[a]=b,a){case"namespace":this._bind();break;case"className":this.$elem.addClass(b)}},this))}},a.fn.onoff=function(c){var d,e,f,g;return"string"==typeof c?(g=[],e=i.call(arguments,1),this.each(function(){d=a.data(this,b.datakey),d?"_"!==c.charAt(0)&&"function"==typeof(f=d[c])&&void 0!==(f=f.apply(d,e))&&g.push(f):g.push(void 0)}),g.length?1===g.length?g[0]:g:this):this.each(function(){new b(this,c)})},a.OnOff=b}); |
+10
-4
@@ -55,4 +55,4 @@ 'use strict'; | ||
| dist: { | ||
| src: ['src/<%= pkg.name %>.js'], | ||
| dest: 'dist/jquery.<%= pkg.name %>.js' | ||
| src: ['src/onoff.js'], | ||
| dest: 'dist/<%= pkg.name %>.js' | ||
| } | ||
@@ -89,2 +89,8 @@ }, | ||
| }, | ||
| dist: { | ||
| options: { | ||
| jshintrc: 'src/.jshintrc' | ||
| }, | ||
| src: ['dist/jquery.onoff.js'] | ||
| }, | ||
| test: { | ||
@@ -124,3 +130,3 @@ options: { | ||
| src: '<%= build.dist.dest %>', | ||
| dest: 'dist/jquery.<%= pkg.name %>.min.js' | ||
| dest: 'dist/<%= pkg.name %>.min.js' | ||
| } | ||
@@ -221,5 +227,5 @@ }, | ||
| 'csslint', | ||
| 'jshint', | ||
| 'version', | ||
| 'build', | ||
| 'jshint', | ||
| 'uglify', | ||
@@ -226,0 +232,0 @@ 'connect', |
@@ -5,3 +5,3 @@ { | ||
| "description": "Interactive, accessible toggle switches for the web", | ||
| "version": "0.2.4", | ||
| "version": "0.3.0", | ||
| "homepage": "https://github.com/timmywil/jquery.onoff", | ||
@@ -8,0 +8,0 @@ "author": { |
+1
-1
| { | ||
| "name": "jquery.onoff", | ||
| "version": "0.2.4", | ||
| "version": "0.3.0", | ||
| "description": "Interactive, accessible toggle switches for the web", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+5
-4
@@ -33,5 +33,5 @@ # On-Off Toggle Switch | ||
| [min]: https://raw.github.com/timmywil/jquery.onoff/0.2.4/dist/jquery.onoff.min.js | ||
| [max]: https://raw.github.com/timmywil/jquery.onoff/0.2.4/dist/jquery.onoff.js | ||
| [css]: https://raw.github.com/timmywil/jquery.onoff/0.2.4/dist/jquery.onoff.css | ||
| [min]: https://raw.github.com/timmywil/jquery.onoff/0.3.0/dist/jquery.onoff.min.js | ||
| [max]: https://raw.github.com/timmywil/jquery.onoff/0.3.0/dist/jquery.onoff.js | ||
| [css]: https://raw.github.com/timmywil/jquery.onoff/0.3.0/dist/jquery.onoff.css | ||
@@ -192,3 +192,4 @@ ### With AMD | ||
| **0.2.4** *3/3/2014* Integrate [jquery.event.pointertouch](https://github.com/timmywil/jquery.event.pointertouch) into build. | ||
| **0.3.0** *3/3/2014* Update to full-blown pointertouch | ||
| **0.2.4** *3/3/2014* Integrate [jquery.event.pointertouch](https://github.com/timmywil/jquery.event.pointertouch) into build. | ||
| **0.1.0** *1/15/2014* First release | ||
@@ -195,0 +196,0 @@ |
+37
-37
| /** | ||
| * jquery.event.pointertouch | ||
| * Lift touch and pointer event properties to the jQuery event object | ||
| * @version v0.0.6 | ||
| * @version v0.1.0 | ||
| * @license MIT | ||
@@ -22,46 +22,46 @@ */ | ||
| // Common properties to lift for touch or pointer events | ||
| var props = [ 'pageX', 'pageY', 'clientX', 'clientY' ]; | ||
| var hook = { props: props }; | ||
| var hook = $.event.mouseHooks; | ||
| var props = hook.props; | ||
| var events = {}; | ||
| var list = 'over out down up move enter leave cancel'.split(' '); | ||
| var touchReplace = { down: 'start', up: 'end' }; | ||
| // Support pointer events in IE11+ if available | ||
| if ( window.PointerEvent ) { | ||
| $.each([ 'pointerdown', 'pointermove', 'pointerup' ], function( i, name ) { | ||
| // Add event name to events property | ||
| events[ name.replace('pointer', '') ] = name; | ||
| $.each(list, function( i, name ) { | ||
| // Add event name to events property and add fixHook | ||
| $.event.fixHooks[ | ||
| (events[name] = 'pointer' + name) | ||
| ] = hook; | ||
| }); | ||
| } else { | ||
| // Add touches property for the touch hook | ||
| props.push('touches', 'changedTouches', 'targetTouches', 'altKey', 'ctrlKey', 'metaKey', 'shiftKey'); | ||
| /** | ||
| * Support: Android | ||
| * Android sets pageX/Y to 0 for any touch event | ||
| * Attach first touch's pageX/pageY and clientX/clientY if not set correctly | ||
| */ | ||
| hook.filter = function( event, originalEvent ) { | ||
| var touch; | ||
| if ( !originalEvent.pageX && originalEvent.touches && (touch = originalEvent.touches[0]) ) { | ||
| event.pageX = touch.pageX; | ||
| event.pageY = touch.pageY; | ||
| event.clientX = touch.clientX; | ||
| event.clientY = touch.clientY; | ||
| } | ||
| return event; | ||
| }; | ||
| // Take off 'over' and 'out' when attaching touch hooks | ||
| $.each(list.slice(2), function( i, name ) { | ||
| var touch = 'touch' + (touchReplace[name] || name); | ||
| // Add fixHook | ||
| $.event.fixHooks[ name ] = hook; | ||
| $.event.fixHooks[ touch ] = hook; | ||
| // Add event names to events property | ||
| events[ name ] = touch + ' mouse' + name; | ||
| }); | ||
| } | ||
| // Add touches property for the touch hook | ||
| props.push('touches'); | ||
| /** | ||
| * Support: Android | ||
| * Android sets pageX/Y to 0 for any touch event | ||
| * Attach first touch's pageX/pageY and clientX/clientY if not set correctly | ||
| */ | ||
| hook.filter = function( event, originalEvent ) { | ||
| var touch; | ||
| if ( !originalEvent.pageX && originalEvent.touches && (touch = originalEvent.touches[0]) ) { | ||
| event.pageX = touch.pageX; | ||
| event.pageY = touch.pageY; | ||
| event.clientX = touch.clientX; | ||
| event.clientY = touch.clientY; | ||
| } | ||
| return event; | ||
| }; | ||
| $.each({ | ||
| mousedown: 'touchstart', | ||
| mousemove: 'touchmove', | ||
| mouseup: 'touchend' | ||
| }, function( mouse, touch ) { | ||
| // Add event names to events property | ||
| events[ mouse.replace('mouse', '') ] = mouse + ' ' + touch; | ||
| // Add fixHook | ||
| $.event.fixHooks[ touch ] = hook; | ||
| }); | ||
| $.pointertouch = events; | ||
@@ -68,0 +68,0 @@ |
@@ -1,9 +0,10 @@ | ||
| /** | ||
| * QUnit v1.12.0 - A JavaScript Unit Testing Framework | ||
| /*! | ||
| * QUnit 1.14.0 | ||
| * http://qunitjs.com/ | ||
| * | ||
| * http://qunitjs.com | ||
| * Copyright 2013 jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Copyright 2012 jQuery Foundation and other contributors | ||
| * Released under the MIT license. | ||
| * http://jquery.org/license | ||
| * Date: 2014-01-31T16:40Z | ||
| */ | ||
@@ -34,13 +35,10 @@ | ||
| color: #8699a4; | ||
| background-color: #0d3349; | ||
| color: #8699A4; | ||
| background-color: #0D3349; | ||
| font-size: 1.5em; | ||
| line-height: 1em; | ||
| font-weight: normal; | ||
| font-weight: 400; | ||
| border-radius: 5px 5px 0 0; | ||
| -moz-border-radius: 5px 5px 0 0; | ||
| -webkit-border-top-right-radius: 5px; | ||
| -webkit-border-top-left-radius: 5px; | ||
| } | ||
@@ -50,3 +48,3 @@ | ||
| text-decoration: none; | ||
| color: #c2ccd1; | ||
| color: #C2CCD1; | ||
| } | ||
@@ -56,3 +54,3 @@ | ||
| #qunit-header a:focus { | ||
| color: #fff; | ||
| color: #FFF; | ||
| } | ||
@@ -62,3 +60,3 @@ | ||
| display: inline-block; | ||
| padding: 0 .5em 0 .1em; | ||
| padding: 0 0.5em 0 0.1em; | ||
| } | ||
@@ -73,3 +71,3 @@ | ||
| color: #5E740B; | ||
| background-color: #eee; | ||
| background-color: #EEE; | ||
| overflow: hidden; | ||
@@ -80,4 +78,4 @@ } | ||
| padding: 0.5em 0 0.5em 2.5em; | ||
| background-color: #2b81af; | ||
| color: #fff; | ||
| background-color: #2B81AF; | ||
| color: #FFF; | ||
| text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; | ||
@@ -98,3 +96,3 @@ } | ||
| padding: 0.4em 0.5em 0.4em 2.5em; | ||
| border-bottom: 1px solid #fff; | ||
| border-bottom: 1px solid #FFF; | ||
| list-style-position: inside; | ||
@@ -113,3 +111,3 @@ } | ||
| padding: 0.5em; | ||
| color: #c2ccd1; | ||
| color: #C2CCD1; | ||
| text-decoration: none; | ||
@@ -131,7 +129,5 @@ } | ||
| background-color: #fff; | ||
| background-color: #FFF; | ||
| border-radius: 5px; | ||
| -moz-border-radius: 5px; | ||
| -webkit-border-radius: 5px; | ||
| } | ||
@@ -145,3 +141,3 @@ | ||
| border-collapse: collapse; | ||
| margin-top: .2em; | ||
| margin-top: 0.2em; | ||
| } | ||
@@ -152,3 +148,3 @@ | ||
| vertical-align: top; | ||
| padding: 0 .5em 0 0; | ||
| padding: 0 0.5em 0 0; | ||
| } | ||
@@ -167,4 +163,4 @@ | ||
| #qunit-tests del { | ||
| background-color: #e0f2be; | ||
| color: #374e0c; | ||
| background-color: #E0F2BE; | ||
| color: #374E0C; | ||
| text-decoration: none; | ||
@@ -174,3 +170,3 @@ } | ||
| #qunit-tests ins { | ||
| background-color: #ffcaca; | ||
| background-color: #FFCACA; | ||
| color: #500; | ||
@@ -182,3 +178,3 @@ text-decoration: none; | ||
| #qunit-tests b.counts { color: black; } | ||
| #qunit-tests b.counts { color: #000; } | ||
| #qunit-tests b.passed { color: #5E740B; } | ||
@@ -189,3 +185,3 @@ #qunit-tests b.failed { color: #710909; } | ||
| padding: 5px; | ||
| background-color: #fff; | ||
| background-color: #FFF; | ||
| border-bottom: none; | ||
@@ -198,4 +194,4 @@ list-style-position: inside; | ||
| #qunit-tests li li.pass { | ||
| color: #3c510c; | ||
| background-color: #fff; | ||
| color: #3C510C; | ||
| background-color: #FFF; | ||
| border-left: 10px solid #C6E746; | ||
@@ -208,3 +204,3 @@ } | ||
| #qunit-tests .pass .test-actual, | ||
| #qunit-tests .pass .test-expected { color: #999999; } | ||
| #qunit-tests .pass .test-expected { color: #999; } | ||
@@ -217,3 +213,3 @@ #qunit-banner.qunit-pass { background-color: #C6E746; } | ||
| color: #710909; | ||
| background-color: #fff; | ||
| background-color: #FFF; | ||
| border-left: 10px solid #EE5757; | ||
@@ -225,13 +221,10 @@ white-space: pre; | ||
| border-radius: 0 0 5px 5px; | ||
| -moz-border-radius: 0 0 5px 5px; | ||
| -webkit-border-bottom-right-radius: 5px; | ||
| -webkit-border-bottom-left-radius: 5px; | ||
| } | ||
| #qunit-tests .fail { color: #000000; background-color: #EE5757; } | ||
| #qunit-tests .fail { color: #000; background-color: #EE5757; } | ||
| #qunit-tests .fail .test-name, | ||
| #qunit-tests .fail .module-name { color: #000000; } | ||
| #qunit-tests .fail .module-name { color: #000; } | ||
| #qunit-tests .fail .test-actual { color: #EE5757; } | ||
| #qunit-tests .fail .test-expected { color: green; } | ||
| #qunit-tests .fail .test-expected { color: #008000; } | ||
@@ -246,9 +239,9 @@ #qunit-banner.qunit-fail { background-color: #EE5757; } | ||
| color: #2b81af; | ||
| color: #2B81AF; | ||
| background-color: #D2E0E6; | ||
| border-bottom: 1px solid white; | ||
| border-bottom: 1px solid #FFF; | ||
| } | ||
| #qunit-testresult .module-name { | ||
| font-weight: bold; | ||
| font-weight: 700; | ||
| } | ||
@@ -255,0 +248,0 @@ |
+652
-576
@@ -1,9 +0,10 @@ | ||
| /** | ||
| * QUnit v1.12.0 - A JavaScript Unit Testing Framework | ||
| /*! | ||
| * QUnit 1.14.0 | ||
| * http://qunitjs.com/ | ||
| * | ||
| * http://qunitjs.com | ||
| * Copyright 2013 jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Copyright 2013 jQuery Foundation and other contributors | ||
| * Released under the MIT license. | ||
| * https://jquery.org/license/ | ||
| * Date: 2014-01-31T16:40Z | ||
| */ | ||
@@ -24,3 +25,5 @@ | ||
| setTimeout = window.setTimeout, | ||
| clearTimeout = window.clearTimeout, | ||
| defined = { | ||
| document: typeof window.document !== "undefined", | ||
| setTimeout: typeof window.setTimeout !== "undefined", | ||
@@ -88,299 +91,3 @@ sessionStorage: (function() { | ||
| function Test( settings ) { | ||
| extend( this, settings ); | ||
| this.assertions = []; | ||
| this.testNumber = ++Test.count; | ||
| } | ||
| Test.count = 0; | ||
| Test.prototype = { | ||
| init: function() { | ||
| var a, b, li, | ||
| tests = id( "qunit-tests" ); | ||
| if ( tests ) { | ||
| b = document.createElement( "strong" ); | ||
| b.innerHTML = this.nameHtml; | ||
| // `a` initialized at top of scope | ||
| a = document.createElement( "a" ); | ||
| a.innerHTML = "Rerun"; | ||
| a.href = QUnit.url({ testNumber: this.testNumber }); | ||
| li = document.createElement( "li" ); | ||
| li.appendChild( b ); | ||
| li.appendChild( a ); | ||
| li.className = "running"; | ||
| li.id = this.id = "qunit-test-output" + testId++; | ||
| tests.appendChild( li ); | ||
| } | ||
| }, | ||
| setup: function() { | ||
| if ( | ||
| // Emit moduleStart when we're switching from one module to another | ||
| this.module !== config.previousModule || | ||
| // They could be equal (both undefined) but if the previousModule property doesn't | ||
| // yet exist it means this is the first test in a suite that isn't wrapped in a | ||
| // module, in which case we'll just emit a moduleStart event for 'undefined'. | ||
| // Without this, reporters can get testStart before moduleStart which is a problem. | ||
| !hasOwn.call( config, "previousModule" ) | ||
| ) { | ||
| if ( hasOwn.call( config, "previousModule" ) ) { | ||
| runLoggingCallbacks( "moduleDone", QUnit, { | ||
| name: config.previousModule, | ||
| failed: config.moduleStats.bad, | ||
| passed: config.moduleStats.all - config.moduleStats.bad, | ||
| total: config.moduleStats.all | ||
| }); | ||
| } | ||
| config.previousModule = this.module; | ||
| config.moduleStats = { all: 0, bad: 0 }; | ||
| runLoggingCallbacks( "moduleStart", QUnit, { | ||
| name: this.module | ||
| }); | ||
| } | ||
| config.current = this; | ||
| this.testEnvironment = extend({ | ||
| setup: function() {}, | ||
| teardown: function() {} | ||
| }, this.moduleTestEnvironment ); | ||
| this.started = +new Date(); | ||
| runLoggingCallbacks( "testStart", QUnit, { | ||
| name: this.testName, | ||
| module: this.module | ||
| }); | ||
| /*jshint camelcase:false */ | ||
| /** | ||
| * Expose the current test environment. | ||
| * | ||
| * @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead. | ||
| */ | ||
| QUnit.current_testEnvironment = this.testEnvironment; | ||
| /*jshint camelcase:true */ | ||
| if ( !config.pollution ) { | ||
| saveGlobal(); | ||
| } | ||
| if ( config.notrycatch ) { | ||
| this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); | ||
| return; | ||
| } | ||
| try { | ||
| this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); | ||
| } catch( e ) { | ||
| QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); | ||
| } | ||
| }, | ||
| run: function() { | ||
| config.current = this; | ||
| var running = id( "qunit-testresult" ); | ||
| if ( running ) { | ||
| running.innerHTML = "Running: <br/>" + this.nameHtml; | ||
| } | ||
| if ( this.async ) { | ||
| QUnit.stop(); | ||
| } | ||
| this.callbackStarted = +new Date(); | ||
| if ( config.notrycatch ) { | ||
| this.callback.call( this.testEnvironment, QUnit.assert ); | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| return; | ||
| } | ||
| try { | ||
| this.callback.call( this.testEnvironment, QUnit.assert ); | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| } catch( e ) { | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); | ||
| // else next test will carry the responsibility | ||
| saveGlobal(); | ||
| // Restart the tests if they're blocking | ||
| if ( config.blocking ) { | ||
| QUnit.start(); | ||
| } | ||
| } | ||
| }, | ||
| teardown: function() { | ||
| config.current = this; | ||
| if ( config.notrycatch ) { | ||
| if ( typeof this.callbackRuntime === "undefined" ) { | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| } | ||
| this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); | ||
| return; | ||
| } else { | ||
| try { | ||
| this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); | ||
| } catch( e ) { | ||
| QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); | ||
| } | ||
| } | ||
| checkPollution(); | ||
| }, | ||
| finish: function() { | ||
| config.current = this; | ||
| if ( config.requireExpects && this.expected === null ) { | ||
| QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack ); | ||
| } else if ( this.expected !== null && this.expected !== this.assertions.length ) { | ||
| QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack ); | ||
| } else if ( this.expected === null && !this.assertions.length ) { | ||
| QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); | ||
| } | ||
| var i, assertion, a, b, time, li, ol, | ||
| test = this, | ||
| good = 0, | ||
| bad = 0, | ||
| tests = id( "qunit-tests" ); | ||
| this.runtime = +new Date() - this.started; | ||
| config.stats.all += this.assertions.length; | ||
| config.moduleStats.all += this.assertions.length; | ||
| if ( tests ) { | ||
| ol = document.createElement( "ol" ); | ||
| ol.className = "qunit-assert-list"; | ||
| for ( i = 0; i < this.assertions.length; i++ ) { | ||
| assertion = this.assertions[i]; | ||
| li = document.createElement( "li" ); | ||
| li.className = assertion.result ? "pass" : "fail"; | ||
| li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" ); | ||
| ol.appendChild( li ); | ||
| if ( assertion.result ) { | ||
| good++; | ||
| } else { | ||
| bad++; | ||
| config.stats.bad++; | ||
| config.moduleStats.bad++; | ||
| } | ||
| } | ||
| // store result when possible | ||
| if ( QUnit.config.reorder && defined.sessionStorage ) { | ||
| if ( bad ) { | ||
| sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad ); | ||
| } else { | ||
| sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName ); | ||
| } | ||
| } | ||
| if ( bad === 0 ) { | ||
| addClass( ol, "qunit-collapsed" ); | ||
| } | ||
| // `b` initialized at top of scope | ||
| b = document.createElement( "strong" ); | ||
| b.innerHTML = this.nameHtml + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>"; | ||
| addEvent(b, "click", function() { | ||
| var next = b.parentNode.lastChild, | ||
| collapsed = hasClass( next, "qunit-collapsed" ); | ||
| ( collapsed ? removeClass : addClass )( next, "qunit-collapsed" ); | ||
| }); | ||
| addEvent(b, "dblclick", function( e ) { | ||
| var target = e && e.target ? e.target : window.event.srcElement; | ||
| if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) { | ||
| target = target.parentNode; | ||
| } | ||
| if ( window.location && target.nodeName.toLowerCase() === "strong" ) { | ||
| window.location = QUnit.url({ testNumber: test.testNumber }); | ||
| } | ||
| }); | ||
| // `time` initialized at top of scope | ||
| time = document.createElement( "span" ); | ||
| time.className = "runtime"; | ||
| time.innerHTML = this.runtime + " ms"; | ||
| // `li` initialized at top of scope | ||
| li = id( this.id ); | ||
| li.className = bad ? "fail" : "pass"; | ||
| li.removeChild( li.firstChild ); | ||
| a = li.firstChild; | ||
| li.appendChild( b ); | ||
| li.appendChild( a ); | ||
| li.appendChild( time ); | ||
| li.appendChild( ol ); | ||
| } else { | ||
| for ( i = 0; i < this.assertions.length; i++ ) { | ||
| if ( !this.assertions[i].result ) { | ||
| bad++; | ||
| config.stats.bad++; | ||
| config.moduleStats.bad++; | ||
| } | ||
| } | ||
| } | ||
| runLoggingCallbacks( "testDone", QUnit, { | ||
| name: this.testName, | ||
| module: this.module, | ||
| failed: bad, | ||
| passed: this.assertions.length - bad, | ||
| total: this.assertions.length, | ||
| duration: this.runtime | ||
| }); | ||
| QUnit.reset(); | ||
| config.current = undefined; | ||
| }, | ||
| queue: function() { | ||
| var bad, | ||
| test = this; | ||
| synchronize(function() { | ||
| test.init(); | ||
| }); | ||
| function run() { | ||
| // each of these can by async | ||
| synchronize(function() { | ||
| test.setup(); | ||
| }); | ||
| synchronize(function() { | ||
| test.run(); | ||
| }); | ||
| synchronize(function() { | ||
| test.teardown(); | ||
| }); | ||
| synchronize(function() { | ||
| test.finish(); | ||
| }); | ||
| } | ||
| // `bad` initialized at top of scope | ||
| // defer when previous test run passed, if storage is available | ||
| bad = QUnit.config.reorder && defined.sessionStorage && | ||
| +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName ); | ||
| if ( bad ) { | ||
| run(); | ||
| } else { | ||
| synchronize( run, true ); | ||
| } | ||
| } | ||
| }; | ||
| // Root QUnit object. | ||
@@ -504,188 +211,4 @@ // `QUnit` initialized at top of scope | ||
| // `assert` initialized at top of scope | ||
| // Assert helpers | ||
| // All of these must either call QUnit.push() or manually do: | ||
| // - runLoggingCallbacks( "log", .. ); | ||
| // - config.current.assertions.push({ .. }); | ||
| // We attach it to the QUnit object *after* we expose the public API, | ||
| // otherwise `assert` will become a global variable in browsers (#341). | ||
| assert = { | ||
| /** | ||
| * Asserts rough true-ish result. | ||
| * @name ok | ||
| * @function | ||
| * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); | ||
| */ | ||
| ok: function( result, msg ) { | ||
| if ( !config.current ) { | ||
| throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) ); | ||
| } | ||
| result = !!result; | ||
| msg = msg || (result ? "okay" : "failed" ); | ||
| var source, | ||
| details = { | ||
| module: config.current.module, | ||
| name: config.current.testName, | ||
| result: result, | ||
| message: msg | ||
| }; | ||
| msg = "<span class='test-message'>" + escapeText( msg ) + "</span>"; | ||
| if ( !result ) { | ||
| source = sourceFromStacktrace( 2 ); | ||
| if ( source ) { | ||
| details.source = source; | ||
| msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr></table>"; | ||
| } | ||
| } | ||
| runLoggingCallbacks( "log", QUnit, details ); | ||
| config.current.assertions.push({ | ||
| result: result, | ||
| message: msg | ||
| }); | ||
| }, | ||
| /** | ||
| * Assert that the first two arguments are equal, with an optional message. | ||
| * Prints out both actual and expected values. | ||
| * @name equal | ||
| * @function | ||
| * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" ); | ||
| */ | ||
| equal: function( actual, expected, message ) { | ||
| /*jshint eqeqeq:false */ | ||
| QUnit.push( expected == actual, actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notEqual | ||
| * @function | ||
| */ | ||
| notEqual: function( actual, expected, message ) { | ||
| /*jshint eqeqeq:false */ | ||
| QUnit.push( expected != actual, actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name propEqual | ||
| * @function | ||
| */ | ||
| propEqual: function( actual, expected, message ) { | ||
| actual = objectValues(actual); | ||
| expected = objectValues(expected); | ||
| QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notPropEqual | ||
| * @function | ||
| */ | ||
| notPropEqual: function( actual, expected, message ) { | ||
| actual = objectValues(actual); | ||
| expected = objectValues(expected); | ||
| QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name deepEqual | ||
| * @function | ||
| */ | ||
| deepEqual: function( actual, expected, message ) { | ||
| QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notDeepEqual | ||
| * @function | ||
| */ | ||
| notDeepEqual: function( actual, expected, message ) { | ||
| QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name strictEqual | ||
| * @function | ||
| */ | ||
| strictEqual: function( actual, expected, message ) { | ||
| QUnit.push( expected === actual, actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notStrictEqual | ||
| * @function | ||
| */ | ||
| notStrictEqual: function( actual, expected, message ) { | ||
| QUnit.push( expected !== actual, actual, expected, message ); | ||
| }, | ||
| "throws": function( block, expected, message ) { | ||
| var actual, | ||
| expectedOutput = expected, | ||
| ok = false; | ||
| // 'expected' is optional | ||
| if ( typeof expected === "string" ) { | ||
| message = expected; | ||
| expected = null; | ||
| } | ||
| config.current.ignoreGlobalErrors = true; | ||
| try { | ||
| block.call( config.current.testEnvironment ); | ||
| } catch (e) { | ||
| actual = e; | ||
| } | ||
| config.current.ignoreGlobalErrors = false; | ||
| if ( actual ) { | ||
| // we don't want to validate thrown error | ||
| if ( !expected ) { | ||
| ok = true; | ||
| expectedOutput = null; | ||
| // expected is a regexp | ||
| } else if ( QUnit.objectType( expected ) === "regexp" ) { | ||
| ok = expected.test( errorString( actual ) ); | ||
| // expected is a constructor | ||
| } else if ( actual instanceof expected ) { | ||
| ok = true; | ||
| // expected is a validation function which returns true is validation passed | ||
| } else if ( expected.call( {}, actual ) === true ) { | ||
| expectedOutput = null; | ||
| ok = true; | ||
| } | ||
| QUnit.push( ok, actual, expectedOutput, message ); | ||
| } else { | ||
| QUnit.pushFailure( message, null, "No exception was thrown." ); | ||
| } | ||
| } | ||
| }; | ||
| /** | ||
| * @deprecated since 1.8.0 | ||
| * Kept assertion helpers in root for backwards compatibility. | ||
| */ | ||
| extend( QUnit, assert ); | ||
| /** | ||
| * @deprecated since 1.9.0 | ||
| * Kept root "raises()" for backwards compatibility. | ||
| * (Note that we don't introduce assert.raises). | ||
| */ | ||
| QUnit.raises = assert[ "throws" ]; | ||
| /** | ||
| * @deprecated since 1.0.0, replaced with error pushes since 1.3.0 | ||
| * Kept to avoid TypeErrors for undefined methods. | ||
| */ | ||
| QUnit.equals = function() { | ||
| QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" ); | ||
| }; | ||
| QUnit.same = function() { | ||
| QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" ); | ||
| }; | ||
| // We want access to the constructor's prototype | ||
| // We use the prototype to distinguish between properties that should | ||
| // be exposed as globals (and in exports) and those that shouldn't | ||
| (function() { | ||
@@ -722,2 +245,5 @@ function F() {} | ||
| // by default, scroll to top of the page when suite is done | ||
| scrolltop: true, | ||
| // when enabled, all tests must call expect() | ||
@@ -754,19 +280,9 @@ requireExpects: false, | ||
| // Export global variables, unless an 'exports' object exists, | ||
| // in that case we assume we're in CommonJS (dealt with on the bottom of the script) | ||
| if ( typeof exports === "undefined" ) { | ||
| extend( window, QUnit.constructor.prototype ); | ||
| // Expose QUnit object | ||
| window.QUnit = QUnit; | ||
| } | ||
| // Initialize more QUnit.config and QUnit.urlParams | ||
| (function() { | ||
| var i, | ||
| var i, current, | ||
| location = window.location || { search: "", protocol: "file:" }, | ||
| params = location.search.slice( 1 ).split( "&" ), | ||
| length = params.length, | ||
| urlParams = {}, | ||
| current; | ||
| urlParams = {}; | ||
@@ -777,5 +293,10 @@ if ( params[ 0 ] ) { | ||
| current[ 0 ] = decodeURIComponent( current[ 0 ] ); | ||
| // allow just a key to turn on a flag, e.g., test.html?noglobals | ||
| current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; | ||
| urlParams[ current[ 0 ] ] = current[ 1 ]; | ||
| if ( urlParams[ current[ 0 ] ] ) { | ||
| urlParams[ current[ 0 ] ] = [].concat( urlParams[ current[ 0 ] ], current[ 1 ] ); | ||
| } else { | ||
| urlParams[ current[ 0 ] ] = current[ 1 ]; | ||
| } | ||
| } | ||
@@ -792,4 +313,13 @@ } | ||
| config.testNumber = parseInt( urlParams.testNumber, 10 ) || null; | ||
| config.testNumber = []; | ||
| if ( urlParams.testNumber ) { | ||
| // Ensure that urlParams.testNumber is an array | ||
| urlParams.testNumber = [].concat( urlParams.testNumber ); | ||
| for ( i = 0; i < urlParams.testNumber.length; i++ ) { | ||
| current = urlParams.testNumber[ i ]; | ||
| config.testNumber.push( parseInt( current, 10 ) ); | ||
| } | ||
| } | ||
| // Figure out if we're running the tests from a server or not | ||
@@ -799,6 +329,3 @@ QUnit.isLocal = location.protocol === "file:"; | ||
| // Extend QUnit object, | ||
| // these after set here because they should not be exposed as global functions | ||
| extend( QUnit, { | ||
| assert: assert, | ||
@@ -872,16 +399,2 @@ config: config, | ||
| // Trigger an event on an element. | ||
| // @example triggerEvent( document.body, "click" ); | ||
| triggerEvent: function( elem, type, event ) { | ||
| if ( document.createEvent ) { | ||
| event = document.createEvent( "MouseEvents" ); | ||
| event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, | ||
| 0, 0, 0, 0, 0, false, false, false, false, 0, null); | ||
| elem.dispatchEvent( event ); | ||
| } else if ( elem.fireEvent ) { | ||
| elem.fireEvent( "on" + type ); | ||
| } | ||
| }, | ||
| // Safe object type checking | ||
@@ -894,7 +407,8 @@ is: function( type, obj ) { | ||
| if ( typeof obj === "undefined" ) { | ||
| return "undefined"; | ||
| // consider: typeof null === object | ||
| return "undefined"; | ||
| } | ||
| // Consider: typeof null === object | ||
| if ( obj === null ) { | ||
| return "null"; | ||
| return "null"; | ||
| } | ||
@@ -1056,3 +570,3 @@ | ||
| // testDone: { name, failed, passed, total, duration } | ||
| // testDone: { name, failed, passed, total, runtime } | ||
| testDone: registerLoggingCallback( "testDone" ), | ||
@@ -1067,3 +581,3 @@ | ||
| if ( typeof document === "undefined" || document.readyState === "complete" ) { | ||
| if ( !defined.document || document.readyState === "complete" ) { | ||
| config.autorun = true; | ||
@@ -1076,4 +590,4 @@ } | ||
| // Initialize the config, saving the execution queue | ||
| var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, | ||
| urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter, | ||
| var banner, filter, i, j, label, len, main, ol, toolbar, val, selection, | ||
| urlConfigContainer, moduleFilter, userAgent, | ||
| numModules = 0, | ||
@@ -1097,13 +611,51 @@ moduleNames = [], | ||
| id: val, | ||
| label: val, | ||
| tooltip: "[no tooltip available]" | ||
| label: val | ||
| }; | ||
| } | ||
| config[ val.id ] = QUnit.urlParams[ val.id ]; | ||
| urlConfigHtml += "<input id='qunit-urlconfig-" + escapeText( val.id ) + | ||
| "' name='" + escapeText( val.id ) + | ||
| "' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) + | ||
| " title='" + escapeText( val.tooltip ) + | ||
| "'><label for='qunit-urlconfig-" + escapeText( val.id ) + | ||
| "' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>"; | ||
| if ( !val.value || typeof val.value === "string" ) { | ||
| urlConfigHtml += "<input id='qunit-urlconfig-" + escapeText( val.id ) + | ||
| "' name='" + escapeText( val.id ) + | ||
| "' type='checkbox'" + | ||
| ( val.value ? " value='" + escapeText( val.value ) + "'" : "" ) + | ||
| ( config[ val.id ] ? " checked='checked'" : "" ) + | ||
| " title='" + escapeText( val.tooltip ) + | ||
| "'><label for='qunit-urlconfig-" + escapeText( val.id ) + | ||
| "' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>"; | ||
| } else { | ||
| urlConfigHtml += "<label for='qunit-urlconfig-" + escapeText( val.id ) + | ||
| "' title='" + escapeText( val.tooltip ) + | ||
| "'>" + val.label + | ||
| ": </label><select id='qunit-urlconfig-" + escapeText( val.id ) + | ||
| "' name='" + escapeText( val.id ) + | ||
| "' title='" + escapeText( val.tooltip ) + | ||
| "'><option></option>"; | ||
| selection = false; | ||
| if ( QUnit.is( "array", val.value ) ) { | ||
| for ( j = 0; j < val.value.length; j++ ) { | ||
| urlConfigHtml += "<option value='" + escapeText( val.value[j] ) + "'" + | ||
| ( config[ val.id ] === val.value[j] ? | ||
| (selection = true) && " selected='selected'" : | ||
| "" ) + | ||
| ">" + escapeText( val.value[j] ) + "</option>"; | ||
| } | ||
| } else { | ||
| for ( j in val.value ) { | ||
| if ( hasOwn.call( val.value, j ) ) { | ||
| urlConfigHtml += "<option value='" + escapeText( j ) + "'" + | ||
| ( config[ val.id ] === j ? | ||
| (selection = true) && " selected='selected'" : | ||
| "" ) + | ||
| ">" + escapeText( val.value[j] ) + "</option>"; | ||
| } | ||
| } | ||
| } | ||
| if ( config[ val.id ] && !selection ) { | ||
| urlConfigHtml += "<option value='" + escapeText( config[ val.id ] ) + | ||
| "' selected='selected' disabled='disabled'>" + | ||
| escapeText( config[ val.id ] ) + | ||
| "</option>"; | ||
| } | ||
| urlConfigHtml += "</select>"; | ||
| } | ||
| } | ||
@@ -1153,3 +705,3 @@ for ( i in config.modules ) { | ||
| var tmp, | ||
| ol = document.getElementById( "qunit-tests" ); | ||
| ol = id( "qunit-tests" ); | ||
@@ -1174,3 +726,3 @@ if ( filter.checked ) { | ||
| // `ol` initialized at top of scope | ||
| ol = document.getElementById( "qunit-tests" ); | ||
| ol = id( "qunit-tests" ); | ||
| ol.className = ol.className + " hidepass"; | ||
@@ -1187,16 +739,23 @@ } | ||
| urlConfigCheckboxesContainer = document.createElement("span"); | ||
| urlConfigCheckboxesContainer.innerHTML = urlConfigHtml; | ||
| urlConfigCheckboxes = urlConfigCheckboxesContainer.getElementsByTagName("input"); | ||
| urlConfigContainer = document.createElement("span"); | ||
| urlConfigContainer.innerHTML = urlConfigHtml; | ||
| // For oldIE support: | ||
| // * Add handlers to the individual elements instead of the container | ||
| // * Use "click" instead of "change" | ||
| // * Use "click" instead of "change" for checkboxes | ||
| // * Fallback from event.target to event.srcElement | ||
| addEvents( urlConfigCheckboxes, "click", function( event ) { | ||
| addEvents( urlConfigContainer.getElementsByTagName("input"), "click", function( event ) { | ||
| var params = {}, | ||
| target = event.target || event.srcElement; | ||
| params[ target.name ] = target.checked ? true : undefined; | ||
| params[ target.name ] = target.checked ? | ||
| target.defaultValue || true : | ||
| undefined; | ||
| window.location = QUnit.url( params ); | ||
| }); | ||
| toolbar.appendChild( urlConfigCheckboxesContainer ); | ||
| addEvents( urlConfigContainer.getElementsByTagName("select"), "change", function( event ) { | ||
| var params = {}, | ||
| target = event.target || event.srcElement; | ||
| params[ target.name ] = target.options[ target.selectedIndex ].value || undefined; | ||
| window.location = QUnit.url( params ); | ||
| }); | ||
| toolbar.appendChild( urlConfigContainer ); | ||
@@ -1233,3 +792,5 @@ if (numModules > 1) { | ||
| addEvent( window, "load", QUnit.load ); | ||
| if ( defined.document ) { | ||
| addEvent( window, "load", QUnit.load ); | ||
| } | ||
@@ -1272,5 +833,5 @@ // `onErrorFnPrev` initialized at top of scope | ||
| // Log the last module results | ||
| if ( config.currentModule ) { | ||
| if ( config.previousModule ) { | ||
| runLoggingCallbacks( "moduleDone", QUnit, { | ||
| name: config.currentModule, | ||
| name: config.previousModule, | ||
| failed: config.moduleStats.bad, | ||
@@ -1309,3 +870,3 @@ passed: config.moduleStats.all - config.moduleStats.bad, | ||
| if ( config.altertitle && typeof document !== "undefined" && document.title ) { | ||
| if ( config.altertitle && defined.document && document.title ) { | ||
| // show ✖ for good, ✔ for bad suite result in title | ||
@@ -1331,3 +892,3 @@ // use escape sequences in case file gets loaded with non-utf-8-charset | ||
| // scroll back to top to show results | ||
| if ( window.scrollTo ) { | ||
| if ( config.scrolltop && window.scrollTo ) { | ||
| window.scrollTo(0, 0); | ||
@@ -1349,3 +910,3 @@ } | ||
| module = config.module && config.module.toLowerCase(), | ||
| fullName = (test.module + ": " + test.testName).toLowerCase(); | ||
| fullName = ( test.module + ": " + test.testName ).toLowerCase(); | ||
@@ -1358,4 +919,6 @@ // Internally-generated tests are always valid | ||
| if ( config.testNumber ) { | ||
| return test.testNumber === config.testNumber; | ||
| if ( config.testNumber.length > 0 ) { | ||
| if ( inArray( test.testNumber, config.testNumber ) < 0 ) { | ||
| return false; | ||
| } | ||
| } | ||
@@ -1562,8 +1125,14 @@ | ||
| function addEvent( elem, type, fn ) { | ||
| // Standards-based browsers | ||
| if ( elem.addEventListener ) { | ||
| // Standards-based browsers | ||
| elem.addEventListener( type, fn, false ); | ||
| // IE | ||
| } else if ( elem.attachEvent ) { | ||
| // support: IE <9 | ||
| elem.attachEvent( "on" + type, fn ); | ||
| } else { | ||
| elem.attachEvent( "on" + type, fn ); | ||
| // Caller must ensure support for event listeners is present | ||
| throw new Error( "addEvent() was called in a context without event listener support" ); | ||
| } | ||
@@ -1605,4 +1174,3 @@ } | ||
| function id( name ) { | ||
| return !!( typeof document !== "undefined" && document && document.getElementById ) && | ||
| document.getElementById( name ); | ||
| return defined.document && document.getElementById && document.getElementById( name ); | ||
| } | ||
@@ -1629,2 +1197,516 @@ | ||
| // from jquery.js | ||
| function inArray( elem, array ) { | ||
| if ( array.indexOf ) { | ||
| return array.indexOf( elem ); | ||
| } | ||
| for ( var i = 0, length = array.length; i < length; i++ ) { | ||
| if ( array[ i ] === elem ) { | ||
| return i; | ||
| } | ||
| } | ||
| return -1; | ||
| } | ||
| function Test( settings ) { | ||
| extend( this, settings ); | ||
| this.assertions = []; | ||
| this.testNumber = ++Test.count; | ||
| } | ||
| Test.count = 0; | ||
| Test.prototype = { | ||
| init: function() { | ||
| var a, b, li, | ||
| tests = id( "qunit-tests" ); | ||
| if ( tests ) { | ||
| b = document.createElement( "strong" ); | ||
| b.innerHTML = this.nameHtml; | ||
| // `a` initialized at top of scope | ||
| a = document.createElement( "a" ); | ||
| a.innerHTML = "Rerun"; | ||
| a.href = QUnit.url({ testNumber: this.testNumber }); | ||
| li = document.createElement( "li" ); | ||
| li.appendChild( b ); | ||
| li.appendChild( a ); | ||
| li.className = "running"; | ||
| li.id = this.id = "qunit-test-output" + testId++; | ||
| tests.appendChild( li ); | ||
| } | ||
| }, | ||
| setup: function() { | ||
| if ( | ||
| // Emit moduleStart when we're switching from one module to another | ||
| this.module !== config.previousModule || | ||
| // They could be equal (both undefined) but if the previousModule property doesn't | ||
| // yet exist it means this is the first test in a suite that isn't wrapped in a | ||
| // module, in which case we'll just emit a moduleStart event for 'undefined'. | ||
| // Without this, reporters can get testStart before moduleStart which is a problem. | ||
| !hasOwn.call( config, "previousModule" ) | ||
| ) { | ||
| if ( hasOwn.call( config, "previousModule" ) ) { | ||
| runLoggingCallbacks( "moduleDone", QUnit, { | ||
| name: config.previousModule, | ||
| failed: config.moduleStats.bad, | ||
| passed: config.moduleStats.all - config.moduleStats.bad, | ||
| total: config.moduleStats.all | ||
| }); | ||
| } | ||
| config.previousModule = this.module; | ||
| config.moduleStats = { all: 0, bad: 0 }; | ||
| runLoggingCallbacks( "moduleStart", QUnit, { | ||
| name: this.module | ||
| }); | ||
| } | ||
| config.current = this; | ||
| this.testEnvironment = extend({ | ||
| setup: function() {}, | ||
| teardown: function() {} | ||
| }, this.moduleTestEnvironment ); | ||
| this.started = +new Date(); | ||
| runLoggingCallbacks( "testStart", QUnit, { | ||
| name: this.testName, | ||
| module: this.module | ||
| }); | ||
| /*jshint camelcase:false */ | ||
| /** | ||
| * Expose the current test environment. | ||
| * | ||
| * @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead. | ||
| */ | ||
| QUnit.current_testEnvironment = this.testEnvironment; | ||
| /*jshint camelcase:true */ | ||
| if ( !config.pollution ) { | ||
| saveGlobal(); | ||
| } | ||
| if ( config.notrycatch ) { | ||
| this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); | ||
| return; | ||
| } | ||
| try { | ||
| this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); | ||
| } catch( e ) { | ||
| QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); | ||
| } | ||
| }, | ||
| run: function() { | ||
| config.current = this; | ||
| var running = id( "qunit-testresult" ); | ||
| if ( running ) { | ||
| running.innerHTML = "Running: <br/>" + this.nameHtml; | ||
| } | ||
| if ( this.async ) { | ||
| QUnit.stop(); | ||
| } | ||
| this.callbackStarted = +new Date(); | ||
| if ( config.notrycatch ) { | ||
| this.callback.call( this.testEnvironment, QUnit.assert ); | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| return; | ||
| } | ||
| try { | ||
| this.callback.call( this.testEnvironment, QUnit.assert ); | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| } catch( e ) { | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); | ||
| // else next test will carry the responsibility | ||
| saveGlobal(); | ||
| // Restart the tests if they're blocking | ||
| if ( config.blocking ) { | ||
| QUnit.start(); | ||
| } | ||
| } | ||
| }, | ||
| teardown: function() { | ||
| config.current = this; | ||
| if ( config.notrycatch ) { | ||
| if ( typeof this.callbackRuntime === "undefined" ) { | ||
| this.callbackRuntime = +new Date() - this.callbackStarted; | ||
| } | ||
| this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); | ||
| return; | ||
| } else { | ||
| try { | ||
| this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); | ||
| } catch( e ) { | ||
| QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); | ||
| } | ||
| } | ||
| checkPollution(); | ||
| }, | ||
| finish: function() { | ||
| config.current = this; | ||
| if ( config.requireExpects && this.expected === null ) { | ||
| QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack ); | ||
| } else if ( this.expected !== null && this.expected !== this.assertions.length ) { | ||
| QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack ); | ||
| } else if ( this.expected === null && !this.assertions.length ) { | ||
| QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); | ||
| } | ||
| var i, assertion, a, b, time, li, ol, | ||
| test = this, | ||
| good = 0, | ||
| bad = 0, | ||
| tests = id( "qunit-tests" ); | ||
| this.runtime = +new Date() - this.started; | ||
| config.stats.all += this.assertions.length; | ||
| config.moduleStats.all += this.assertions.length; | ||
| if ( tests ) { | ||
| ol = document.createElement( "ol" ); | ||
| ol.className = "qunit-assert-list"; | ||
| for ( i = 0; i < this.assertions.length; i++ ) { | ||
| assertion = this.assertions[i]; | ||
| li = document.createElement( "li" ); | ||
| li.className = assertion.result ? "pass" : "fail"; | ||
| li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" ); | ||
| ol.appendChild( li ); | ||
| if ( assertion.result ) { | ||
| good++; | ||
| } else { | ||
| bad++; | ||
| config.stats.bad++; | ||
| config.moduleStats.bad++; | ||
| } | ||
| } | ||
| // store result when possible | ||
| if ( QUnit.config.reorder && defined.sessionStorage ) { | ||
| if ( bad ) { | ||
| sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad ); | ||
| } else { | ||
| sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName ); | ||
| } | ||
| } | ||
| if ( bad === 0 ) { | ||
| addClass( ol, "qunit-collapsed" ); | ||
| } | ||
| // `b` initialized at top of scope | ||
| b = document.createElement( "strong" ); | ||
| b.innerHTML = this.nameHtml + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>"; | ||
| addEvent(b, "click", function() { | ||
| var next = b.parentNode.lastChild, | ||
| collapsed = hasClass( next, "qunit-collapsed" ); | ||
| ( collapsed ? removeClass : addClass )( next, "qunit-collapsed" ); | ||
| }); | ||
| addEvent(b, "dblclick", function( e ) { | ||
| var target = e && e.target ? e.target : window.event.srcElement; | ||
| if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) { | ||
| target = target.parentNode; | ||
| } | ||
| if ( window.location && target.nodeName.toLowerCase() === "strong" ) { | ||
| window.location = QUnit.url({ testNumber: test.testNumber }); | ||
| } | ||
| }); | ||
| // `time` initialized at top of scope | ||
| time = document.createElement( "span" ); | ||
| time.className = "runtime"; | ||
| time.innerHTML = this.runtime + " ms"; | ||
| // `li` initialized at top of scope | ||
| li = id( this.id ); | ||
| li.className = bad ? "fail" : "pass"; | ||
| li.removeChild( li.firstChild ); | ||
| a = li.firstChild; | ||
| li.appendChild( b ); | ||
| li.appendChild( a ); | ||
| li.appendChild( time ); | ||
| li.appendChild( ol ); | ||
| } else { | ||
| for ( i = 0; i < this.assertions.length; i++ ) { | ||
| if ( !this.assertions[i].result ) { | ||
| bad++; | ||
| config.stats.bad++; | ||
| config.moduleStats.bad++; | ||
| } | ||
| } | ||
| } | ||
| runLoggingCallbacks( "testDone", QUnit, { | ||
| name: this.testName, | ||
| module: this.module, | ||
| failed: bad, | ||
| passed: this.assertions.length - bad, | ||
| total: this.assertions.length, | ||
| runtime: this.runtime, | ||
| // DEPRECATED: this property will be removed in 2.0.0, use runtime instead | ||
| duration: this.runtime | ||
| }); | ||
| QUnit.reset(); | ||
| config.current = undefined; | ||
| }, | ||
| queue: function() { | ||
| var bad, | ||
| test = this; | ||
| synchronize(function() { | ||
| test.init(); | ||
| }); | ||
| function run() { | ||
| // each of these can by async | ||
| synchronize(function() { | ||
| test.setup(); | ||
| }); | ||
| synchronize(function() { | ||
| test.run(); | ||
| }); | ||
| synchronize(function() { | ||
| test.teardown(); | ||
| }); | ||
| synchronize(function() { | ||
| test.finish(); | ||
| }); | ||
| } | ||
| // `bad` initialized at top of scope | ||
| // defer when previous test run passed, if storage is available | ||
| bad = QUnit.config.reorder && defined.sessionStorage && | ||
| +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName ); | ||
| if ( bad ) { | ||
| run(); | ||
| } else { | ||
| synchronize( run, true ); | ||
| } | ||
| } | ||
| }; | ||
| // `assert` initialized at top of scope | ||
| // Assert helpers | ||
| // All of these must either call QUnit.push() or manually do: | ||
| // - runLoggingCallbacks( "log", .. ); | ||
| // - config.current.assertions.push({ .. }); | ||
| assert = QUnit.assert = { | ||
| /** | ||
| * Asserts rough true-ish result. | ||
| * @name ok | ||
| * @function | ||
| * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); | ||
| */ | ||
| ok: function( result, msg ) { | ||
| if ( !config.current ) { | ||
| throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) ); | ||
| } | ||
| result = !!result; | ||
| msg = msg || ( result ? "okay" : "failed" ); | ||
| var source, | ||
| details = { | ||
| module: config.current.module, | ||
| name: config.current.testName, | ||
| result: result, | ||
| message: msg | ||
| }; | ||
| msg = "<span class='test-message'>" + escapeText( msg ) + "</span>"; | ||
| if ( !result ) { | ||
| source = sourceFromStacktrace( 2 ); | ||
| if ( source ) { | ||
| details.source = source; | ||
| msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + | ||
| escapeText( source ) + | ||
| "</pre></td></tr></table>"; | ||
| } | ||
| } | ||
| runLoggingCallbacks( "log", QUnit, details ); | ||
| config.current.assertions.push({ | ||
| result: result, | ||
| message: msg | ||
| }); | ||
| }, | ||
| /** | ||
| * Assert that the first two arguments are equal, with an optional message. | ||
| * Prints out both actual and expected values. | ||
| * @name equal | ||
| * @function | ||
| * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" ); | ||
| */ | ||
| equal: function( actual, expected, message ) { | ||
| /*jshint eqeqeq:false */ | ||
| QUnit.push( expected == actual, actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notEqual | ||
| * @function | ||
| */ | ||
| notEqual: function( actual, expected, message ) { | ||
| /*jshint eqeqeq:false */ | ||
| QUnit.push( expected != actual, actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name propEqual | ||
| * @function | ||
| */ | ||
| propEqual: function( actual, expected, message ) { | ||
| actual = objectValues(actual); | ||
| expected = objectValues(expected); | ||
| QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notPropEqual | ||
| * @function | ||
| */ | ||
| notPropEqual: function( actual, expected, message ) { | ||
| actual = objectValues(actual); | ||
| expected = objectValues(expected); | ||
| QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name deepEqual | ||
| * @function | ||
| */ | ||
| deepEqual: function( actual, expected, message ) { | ||
| QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notDeepEqual | ||
| * @function | ||
| */ | ||
| notDeepEqual: function( actual, expected, message ) { | ||
| QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name strictEqual | ||
| * @function | ||
| */ | ||
| strictEqual: function( actual, expected, message ) { | ||
| QUnit.push( expected === actual, actual, expected, message ); | ||
| }, | ||
| /** | ||
| * @name notStrictEqual | ||
| * @function | ||
| */ | ||
| notStrictEqual: function( actual, expected, message ) { | ||
| QUnit.push( expected !== actual, actual, expected, message ); | ||
| }, | ||
| "throws": function( block, expected, message ) { | ||
| var actual, | ||
| expectedOutput = expected, | ||
| ok = false; | ||
| // 'expected' is optional | ||
| if ( !message && typeof expected === "string" ) { | ||
| message = expected; | ||
| expected = null; | ||
| } | ||
| config.current.ignoreGlobalErrors = true; | ||
| try { | ||
| block.call( config.current.testEnvironment ); | ||
| } catch (e) { | ||
| actual = e; | ||
| } | ||
| config.current.ignoreGlobalErrors = false; | ||
| if ( actual ) { | ||
| // we don't want to validate thrown error | ||
| if ( !expected ) { | ||
| ok = true; | ||
| expectedOutput = null; | ||
| // expected is an Error object | ||
| } else if ( expected instanceof Error ) { | ||
| ok = actual instanceof Error && | ||
| actual.name === expected.name && | ||
| actual.message === expected.message; | ||
| // expected is a regexp | ||
| } else if ( QUnit.objectType( expected ) === "regexp" ) { | ||
| ok = expected.test( errorString( actual ) ); | ||
| // expected is a string | ||
| } else if ( QUnit.objectType( expected ) === "string" ) { | ||
| ok = expected === errorString( actual ); | ||
| // expected is a constructor | ||
| } else if ( actual instanceof expected ) { | ||
| ok = true; | ||
| // expected is a validation function which returns true is validation passed | ||
| } else if ( expected.call( {}, actual ) === true ) { | ||
| expectedOutput = null; | ||
| ok = true; | ||
| } | ||
| QUnit.push( ok, actual, expectedOutput, message ); | ||
| } else { | ||
| QUnit.pushFailure( message, null, "No exception was thrown." ); | ||
| } | ||
| } | ||
| }; | ||
| /** | ||
| * @deprecated since 1.8.0 | ||
| * Kept assertion helpers in root for backwards compatibility. | ||
| */ | ||
| extend( QUnit.constructor.prototype, assert ); | ||
| /** | ||
| * @deprecated since 1.9.0 | ||
| * Kept to avoid TypeErrors for undefined methods. | ||
| */ | ||
| QUnit.constructor.prototype.raises = function() { | ||
| QUnit.push( false, false, false, "QUnit.raises has been deprecated since 2012 (fad3c1ea), use QUnit.throws instead" ); | ||
| }; | ||
| /** | ||
| * @deprecated since 1.0.0, replaced with error pushes since 1.3.0 | ||
| * Kept to avoid TypeErrors for undefined methods. | ||
| */ | ||
| QUnit.constructor.prototype.equals = function() { | ||
| QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" ); | ||
| }; | ||
| QUnit.constructor.prototype.same = function() { | ||
| QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" ); | ||
| }; | ||
| // Test for equality any JavaScript type. | ||
@@ -2069,17 +2151,2 @@ // Author: Philippe Rathé <prathe@gmail.com> | ||
| // from jquery.js | ||
| function inArray( elem, array ) { | ||
| if ( array.indexOf ) { | ||
| return array.indexOf( elem ); | ||
| } | ||
| for ( var i = 0, length = array.length; i < length; i++ ) { | ||
| if ( array[ i ] === elem ) { | ||
| return i; | ||
| } | ||
| } | ||
| return -1; | ||
| } | ||
| /* | ||
@@ -2233,8 +2300,17 @@ * Javascript Diff Algorithm | ||
| // for CommonJS environments, export everything | ||
| if ( typeof exports !== "undefined" ) { | ||
| extend( exports, QUnit.constructor.prototype ); | ||
| // For browser, export only select globals | ||
| if ( typeof window !== "undefined" ) { | ||
| extend( window, QUnit.constructor.prototype ); | ||
| window.QUnit = QUnit; | ||
| } | ||
| // get at whatever the global object is, like window in browsers | ||
| }( (function() {return this;}.call()) )); | ||
| // For CommonJS environments, export everything | ||
| if ( typeof module !== "undefined" && module.exports ) { | ||
| module.exports = QUnit; | ||
| } | ||
| // Get a reference to the global object, like window in browsers | ||
| }( (function() { | ||
| return this; | ||
| })() )); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
479663
0.51%13461
0.49%200
0.5%70
1.45%