cash-dom
Advanced tools
Comparing version 2.3.7 to 2.3.8
@@ -905,8 +905,11 @@ /* MIT https://github.com/kenwheeler/cash */ | ||
return this.each(function (i, ele) { | ||
if (selectMultipleRe.test(ele.type) && isArray(value)) { | ||
var isMultiple = selectMultipleRe.test(ele.type), | ||
eleValue = value === null ? isMultiple ? [] : '' : value; | ||
if (isMultiple && isArray(eleValue)) { | ||
each(ele.options, function (option) { | ||
option.selected = value.indexOf(option.value) >= 0; | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
}); | ||
} else { | ||
ele.value = value; | ||
ele.value = eleValue; | ||
} | ||
@@ -941,18 +944,29 @@ }); | ||
var fragment; | ||
var fragmentRe = /^\s*<(\w+)[^>]*>/, | ||
singleTagRe = /^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/; | ||
var containers; | ||
function initFragment() { | ||
if (fragment) return; | ||
fragment = doc.implementation.createHTMLDocument(''); | ||
var base = fragment.createElement('base'); | ||
base.href = doc.location.href; | ||
fragment.head.appendChild(base); | ||
function initContainers() { | ||
if (containers) return; | ||
var table = doc.createElement('table'), | ||
tr = doc.createElement('tr'); | ||
containers = { | ||
'*': doc.createElement('div'), | ||
tr: doc.createElement('tbody'), | ||
td: tr, | ||
th: tr, | ||
thead: table, | ||
tbody: table, | ||
tfoot: table | ||
}; | ||
} | ||
function parseHTML(html) { | ||
//FIXME: `<tr></tr>` can't be parsed with this | ||
initFragment(); | ||
if (!isString(html)) html = ''; | ||
fragment.body.innerHTML = html; | ||
return $(fragment.body.childNodes).detach().get(); | ||
initContainers(); | ||
if (!isString(html)) return []; | ||
if (singleTagRe.test(html)) return [doc.createElement(RegExp.$1)]; | ||
var fragment = fragmentRe.test(html) && RegExp.$1, | ||
container = containers[fragment] || containers['*']; | ||
container.innerHTML = html; | ||
return $(container.childNodes).detach().get(); | ||
} | ||
@@ -1000,2 +1014,3 @@ | ||
function insertContent(parent, child, prepend) { | ||
if (child === undefined) return; | ||
var isStr = isString(child); | ||
@@ -1002,0 +1017,0 @@ |
@@ -916,8 +916,11 @@ /* MIT https://github.com/kenwheeler/cash */ | ||
return this.each(function (i, ele) { | ||
if (selectMultipleRe.test(ele.type) && isArray(value)) { | ||
var isMultiple = selectMultipleRe.test(ele.type), | ||
eleValue = value === null ? isMultiple ? [] : '' : value; | ||
if (isMultiple && isArray(eleValue)) { | ||
each(ele.options, function (option) { | ||
option.selected = value.indexOf(option.value) >= 0; | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
}); | ||
} else { | ||
ele.value = value; | ||
ele.value = eleValue; | ||
} | ||
@@ -952,18 +955,29 @@ }); | ||
var fragment; | ||
var fragmentRe = /^\s*<(\w+)[^>]*>/, | ||
singleTagRe = /^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/; | ||
var containers; | ||
function initFragment() { | ||
if (fragment) return; | ||
fragment = doc.implementation.createHTMLDocument(''); | ||
var base = fragment.createElement('base'); | ||
base.href = doc.location.href; | ||
fragment.head.appendChild(base); | ||
function initContainers() { | ||
if (containers) return; | ||
var table = doc.createElement('table'), | ||
tr = doc.createElement('tr'); | ||
containers = { | ||
'*': doc.createElement('div'), | ||
tr: doc.createElement('tbody'), | ||
td: tr, | ||
th: tr, | ||
thead: table, | ||
tbody: table, | ||
tfoot: table | ||
}; | ||
} | ||
function parseHTML(html) { | ||
//FIXME: `<tr></tr>` can't be parsed with this | ||
initFragment(); | ||
if (!isString(html)) html = ''; | ||
fragment.body.innerHTML = html; | ||
return $(fragment.body.childNodes).detach().get(); | ||
initContainers(); | ||
if (!isString(html)) return []; | ||
if (singleTagRe.test(html)) return [doc.createElement(RegExp.$1)]; | ||
var fragment = fragmentRe.test(html) && RegExp.$1, | ||
container = containers[fragment] || containers['*']; | ||
container.innerHTML = html; | ||
return $(container.childNodes).detach().get(); | ||
} | ||
@@ -1011,2 +1025,3 @@ | ||
function insertContent(parent, child, prepend) { | ||
if (child === undefined) return; | ||
var isStr = isString(child); | ||
@@ -1013,0 +1028,0 @@ |
@@ -24,5 +24,5 @@ /* MIT https://github.com/kenwheeler/cash */ | ||
y.serialize=function(){var a="";this.each(function(b,c){A(c.elements||[c],function(b){if(!b.disabled&&b.name&&"FIELDSET"!==b.tagName&&!ua.test(b.type)&&(!va.test(b.type)||b.checked)){var c=W(b);void 0!==c&&(c=E(c)?c:[c],A(c,function(c){var d=a;c="&"+encodeURIComponent(b.name)+"="+encodeURIComponent(c).replace(ta,"+");a=d+c}))}})});return a.substr(1)}; | ||
y.val=function(a){return void 0===a?this[0]&&W(this[0]):this.each(function(b,c){V.test(c.type)&&E(a)?A(c.options,function(b){b.selected=0<=a.indexOf(b.value)}):c.value=a})};y.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};y.detach=function(){return this.each(function(a,b){b.parentNode&&b.parentNode.removeChild(b)})};var X; | ||
function v(a){if(!X){X=e.implementation.createHTMLDocument("");var b=X.createElement("base");b.href=e.location.href;X.head.appendChild(b)}u(a)||(a="");X.body.innerHTML=a;return $(X.body.childNodes).detach().get()}x.parseHTML=v;y.empty=function(){var a=this[0];if(a)for(;a.firstChild;)a.removeChild(a.firstChild);return this}; | ||
function Y(a,b,c){var d=u(b);!d&&b.length?A(b,function(b){return Y(a,b,c)}):A(a,d?function(a){a.insertAdjacentHTML(c?"afterbegin":"beforeend",b)}:function(a,d){d=d?b.cloneNode(!0):b;c?a.insertBefore(d,a.childNodes[0]):a.appendChild(d)})}y.append=function(){var a=this;A(arguments,function(b){Y(a,b)});return this};y.appendTo=function(a){Y(x(a),this);return this}; | ||
y.val=function(a){return void 0===a?this[0]&&W(this[0]):this.each(function(b,c){b=V.test(c.type);var d=null===a?b?[]:"":a;b&&E(d)?A(c.options,function(a){a.selected=0<=d.indexOf(a.value)}):c.value=d})};y.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};y.detach=function(){return this.each(function(a,b){b.parentNode&&b.parentNode.removeChild(b)})};var wa=/^\s*<(\w+)[^>]*>/,xa=/^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/,X; | ||
function v(a){if(!X){var b=e.createElement("table"),c=e.createElement("tr");X={"*":e.createElement("div"),tr:e.createElement("tbody"),td:c,th:c,thead:b,tbody:b,tfoot:b}}if(!u(a))return[];if(xa.test(a))return[e.createElement(RegExp.$1)];b=wa.test(a)&&RegExp.$1;b=X[b]||X["*"];b.innerHTML=a;return $(b.childNodes).detach().get()}x.parseHTML=v;y.empty=function(){var a=this[0];if(a)for(;a.firstChild;)a.removeChild(a.firstChild);return this}; | ||
function Y(a,b,c){if(void 0!==b){var d=u(b);!d&&b.length?A(b,function(b){return Y(a,b,c)}):A(a,d?function(a){a.insertAdjacentHTML(c?"afterbegin":"beforeend",b)}:function(a,d){d=d?b.cloneNode(!0):b;c?a.insertBefore(d,a.childNodes[0]):a.appendChild(d)})}}y.append=function(){var a=this;A(arguments,function(b){Y(a,b)});return this};y.appendTo=function(a){Y(x(a),this);return this}; | ||
y.html=function(a){if(void 0===a)return this[0]&&this[0].innerHTML;var b=a.nodeType?a[0].outerHTML:a;return this.each(function(a,d){d.innerHTML=b})};y.insertAfter=function(a){var b=this;x(a).each(function(a,d){var c=d.parentNode;b.each(function(b,f){c.insertBefore(a?f.cloneNode(!0):f,d.nextSibling)})});return this};y.after=function(){var a=this;A(n.apply(arguments),function(b){n.apply(x(b).slice()).insertAfter(a)});return this}; | ||
@@ -29,0 +29,0 @@ y.insertBefore=function(a){var b=this;x(a).each(function(a,d){var c=d.parentNode;b.each(function(b,f){c.insertBefore(a?f.cloneNode(!0):f,d)})});return this};y.before=function(){var a=this;A(arguments,function(b){x(b).insertBefore(a)});return this};y.prepend=function(){var a=this;A(arguments,function(b){Y(a,b,!0)});return this};y.prependTo=function(a){Y(x(a),n.apply(this.slice()),!0);return this};y.remove=function(){return this.detach().off()}; |
@@ -7,3 +7,3 @@ | ||
const SauceLabsLaunchers = { | ||
sauce_ie_10: { | ||
win_ie_10: { | ||
base: 'SauceLabs', | ||
@@ -14,3 +14,3 @@ browserName: 'internet explorer', | ||
}, | ||
sauce_ie_11: { | ||
win_ie_11: { | ||
base: 'SauceLabs', | ||
@@ -21,33 +21,65 @@ browserName: 'internet explorer', | ||
}, | ||
sauce_edge_15: { | ||
win_edge_17: { | ||
base: 'SauceLabs', | ||
browserName: 'MicrosoftEdge', | ||
version: '15.15063' | ||
version: '17.17134', | ||
platform: 'Windows 10' | ||
}, | ||
sauce_edge_17: { | ||
win_chrome_60: { | ||
base: 'SauceLabs', | ||
browserName: 'MicrosoftEdge', | ||
version: '17.17134' | ||
browserName: 'chrome', | ||
version: '60.0', | ||
platform: 'Windows 10' | ||
}, | ||
sauce_safari: { | ||
win_firefox_50: { | ||
base: 'SauceLabs', | ||
browserName: 'Safari', | ||
version: '11.1', | ||
browserName: 'firefox', | ||
version: '50.0', | ||
platform: 'Windows 10' | ||
}, | ||
linux_chrome_45: { | ||
base: 'SauceLabs', | ||
browserName: 'chrome', | ||
version: '45.0', | ||
platform: 'Linux' | ||
}, | ||
linux_firefox_45: { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
version: '45.0', | ||
platform: 'Linux' | ||
}, | ||
mac_chrome_60: { | ||
base: 'SauceLabs', | ||
browserName: 'chrome', | ||
version: '60.0', | ||
platform: 'macOS 10.13' | ||
}, | ||
sauce_iphone: { | ||
mac_firefox_50: { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
version: '50.0', | ||
platform: 'macOS 10.13' | ||
}, | ||
mac_safari_12: { | ||
base: 'SauceLabs', | ||
browserName: 'safari', | ||
version: '12.0', | ||
platform: 'macOS 10.13' | ||
}, | ||
ios_9: { | ||
base: 'SauceLabs', | ||
deviceName: 'iPhone 6 Simulator', | ||
browserName: 'Safari', | ||
deviceName: 'iPhone XS Simulator', | ||
platformName: 'iOS', | ||
platformVersion: '12.0' | ||
platformVersion: '9.3', | ||
platformName: 'iOS' | ||
}, | ||
sauce_android_kitkat: { | ||
ios_12: { | ||
base: 'SauceLabs', | ||
deviceName: 'Android Emulator', | ||
browserName: 'Browser', | ||
platformVersion: '4.4', | ||
platformName: 'Android' | ||
deviceName: 'iPhone XS Simulator', | ||
browserName: 'Safari', | ||
platformVersion: '12.0', | ||
platformName: 'iOS' | ||
}, | ||
sauce_android_marshmallow: { | ||
android_6: { | ||
base: 'SauceLabs', | ||
@@ -54,0 +86,0 @@ deviceName: 'Android Emulator', |
{ | ||
"name": "cash-dom", | ||
"description": "An absurdly small jQuery alternative for modern browsers.", | ||
"version": "2.3.7", | ||
"version": "2.3.8", | ||
"license": "MIT", | ||
@@ -40,3 +40,3 @@ "main": "./dist/cash.js", | ||
"devDependencies": { | ||
"browser-sync": "^2.24.4", | ||
"browser-sync": "^2.26.3", | ||
"jquery": "^3.3.1", | ||
@@ -49,5 +49,5 @@ "karma": "^3.0.0", | ||
"opn-cli": "^3.1.0", | ||
"pacco": "^1.3.4", | ||
"qunit": "^2.6.2" | ||
"pacco": "^1.3.7", | ||
"qunit": "^2.7.1" | ||
} | ||
} |
@@ -22,6 +22,6 @@ | ||
Get cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/2.3.3/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@2.3.3/dist/cash.min.js) and use it like this: | ||
Get cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/2.3.7/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@2.3.7/dist/cash.min.js) and use it like this: | ||
```html | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/2.3.3/cash.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/2.3.7/cash.min.js"></script> | ||
<script> | ||
@@ -28,0 +28,0 @@ $(function () { |
@@ -8,19 +8,43 @@ | ||
let fragment; | ||
const fragmentRe = /^\s*<(\w+)[^>]*>/, | ||
singleTagRe = /^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/; | ||
function initFragment () { | ||
if ( fragment ) return; | ||
fragment = doc.implementation.createHTMLDocument ( '' ); | ||
const base = fragment.createElement ( 'base' ); | ||
base.href = doc.location.href; | ||
fragment.head.appendChild ( base ); | ||
let containers; | ||
function initContainers () { | ||
if ( containers ) return; | ||
const table = doc.createElement ( 'table' ), | ||
tr = doc.createElement ( 'tr' ); | ||
containers = { | ||
'*': doc.createElement ( 'div' ), | ||
tr: doc.createElement ( 'tbody' ), | ||
td: tr, | ||
th: tr, | ||
thead: table, | ||
tbody: table, | ||
tfoot: table, | ||
}; | ||
} | ||
function parseHTML ( html ) { //FIXME: `<tr></tr>` can't be parsed with this | ||
initFragment (); | ||
if ( !isString ( html ) ) html = ''; | ||
fragment.body.innerHTML = html; | ||
return $(fragment.body.childNodes).detach ().get (); | ||
function parseHTML ( html ) { | ||
initContainers (); | ||
if ( !isString ( html ) ) return []; | ||
if ( singleTagRe.test ( html ) ) return [doc.createElement ( RegExp.$1 )]; | ||
const fragment = fragmentRe.test ( html ) && RegExp.$1, | ||
container = containers[fragment] || containers['*']; | ||
container.innerHTML = html; | ||
return $(container.childNodes).detach ().get (); | ||
} | ||
cash.parseHTML = parseHTML; |
@@ -14,7 +14,10 @@ | ||
if ( selectMultipleRe.test ( ele.type ) && isArray ( value ) ) { | ||
const isMultiple = selectMultipleRe.test ( ele.type ), | ||
eleValue = ( value === null ) ? ( isMultiple ? [] : '' ) : value; | ||
if ( isMultiple && isArray ( eleValue ) ) { | ||
each ( ele.options, option => { | ||
option.selected = value.indexOf ( option.value ) >= 0; | ||
option.selected = eleValue.indexOf ( option.value ) >= 0; | ||
@@ -25,3 +28,3 @@ }); | ||
ele.value = value; | ||
ele.value = eleValue; | ||
@@ -28,0 +31,0 @@ } |
@@ -8,2 +8,4 @@ | ||
if ( child === undefined ) return; | ||
const isStr = isString ( child ); | ||
@@ -10,0 +12,0 @@ |
@@ -47,35 +47,35 @@ | ||
QUnit.test( "className Query", function( assert ) { | ||
assert.equal($('.class-fixture').length, 1, "className Passed!" ); | ||
assert.equal($('.class-fixture').length, 1, "className" ); | ||
}); | ||
QUnit.test( "tagName Query", function( assert ) { | ||
assert.equal($('fieldset').length, 1, "tagName Passed!" ); | ||
assert.equal($('fieldset').length, 1, "tagName" ); | ||
}); | ||
QUnit.test( "id Query", function( assert ) { | ||
assert.equal($('#id-fixture').length, 1, "id Passed!" ); | ||
assert.equal($('#id-fixture').length, 1, "id" ); | ||
}); | ||
QUnit.test( "qSA Query", function( assert ) { | ||
assert.equal($('.qsa-fixture').length, 2, "qSA Passed!" ); | ||
assert.equal($('.qsa-fixture').length, 2, "qSA" ); | ||
}); | ||
QUnit.test( "domNode Query", function( assert ) { | ||
assert.equal($($('.qsa-fixture')[0]).length, 1, " domNode Passed!" ); | ||
assert.equal($($('.qsa-fixture')[0]).length, 1, " domNode" ); | ||
}); | ||
QUnit.test( "HTML Query/Init", function( assert ) { | ||
assert.equal($('<div class="html-fixture">').length, 1, "HTML Passed!" ); | ||
assert.equal($('<div class="html-fixture">').length, 1, "HTML" ); | ||
}); | ||
QUnit.test( "tagName which doesnt exist Query", function( assert ) { | ||
assert.equal($('foo').length, 0, "tagName which doenst exist Passed!" ); | ||
assert.equal($('foo').length, 0, "tagName which doenst exist" ); | ||
}); | ||
QUnit.test( "id Query for non-existing element", function( assert ) { | ||
assert.equal($('#i-dont-exist').length, 0, "id for non-existing element Passed!" ); | ||
assert.equal($('#i-dont-exist').length, 0, "id for non-existing element" ); | ||
}); | ||
QUnit.test( "className Query for non-existing element", function( assert ) { | ||
assert.equal($('.i-dont-exist').length, 0, "className for non-existing element Passed!" ); | ||
assert.equal($('.i-dont-exist').length, 0, "className for non-existing element" ); | ||
}); | ||
@@ -109,11 +109,11 @@ | ||
$('.class-fixture').addClass('add-class'); | ||
assert.equal($('.add-class').length, 1, "addClass Passed!" ); | ||
assert.equal($('.add-class').length, 1, "addClass" ); | ||
$('.class-fixture').addClass('add-class class-two'); | ||
assert.equal($('.add-class.class-two').length, 1, "addClass multiple classes Passed!" ); | ||
assert.equal($('.add-class.class-two').length, 1, "addClass multiple classes" ); | ||
$('.class-fixture').addClass('add-class add-class class-two add-class'); | ||
$('.class-fixture').addClass('class-two add-class add-class add-class'); | ||
var dupes = $('.class-fixture')[0].className.match(/add-class/g); | ||
assert.equal(dupes.length, 1, "addClass no duplicates Passed!" ); | ||
assert.equal(dupes.length, 1, "addClass no duplicates" ); | ||
$('.qsa-fixture').addClass('add-class-multiple'); | ||
assert.equal($('.add-class-multiple').length, 2, "addClass multiple elements Passed!" ); | ||
assert.equal($('.add-class-multiple').length, 2, "addClass multiple elements" ); | ||
}); | ||
@@ -123,7 +123,7 @@ | ||
var testAttr = $('.attr-fixture').attr('success'); | ||
assert.equal(testAttr, 'get', "attr get Passed!" ); | ||
assert.equal(testAttr, 'get', "attr get" ); | ||
$('.attr-fixture').attr('success','set'); | ||
testAttr = $('.attr-fixture').attr('success'); | ||
assert.equal(testAttr, 'set', "attr set Passed!" ); | ||
assert.equal(testAttr, 'set', "attr set" ); | ||
@@ -133,3 +133,3 @@ var testReturn = $('.attr-fixture').attr({ 'success': 'set', 'multi-success': 'set' }); | ||
assert.equal(testReturn instanceof cash, true, "attr set returns collection!" ); | ||
assert.equal(testAttr, 'set set', "attr set multiple Passed!" ); | ||
assert.equal(testAttr, 'set set', "attr set multiple" ); | ||
@@ -155,6 +155,6 @@ testAttr = $('.attr-fixture, .attr-fixture2').attr("nothing"); | ||
var hasClass = $('.attr-fixture').hasClass('has-class'); | ||
assert.equal(hasClass, true, "hasClass (true) Passed!" ); | ||
assert.equal(hasClass, true, "hasClass (true)" ); | ||
hasClass = $('.attr-fixture').hasClass('not-a-real-class'); | ||
assert.equal(hasClass, false, "hasClass (false) Passed!" ); | ||
assert.equal(hasClass, false, "hasClass (false)" ); | ||
@@ -166,6 +166,6 @@ hasClass = $('.attr-fixture').addClass('foo$bar').hasClass('foo$bar'); | ||
QUnit.test( "prop", function( assert ) { | ||
assert.equal($('.prop-fixture').prop('checked'), true, "prop get Passed!" ); | ||
assert.equal($('.prop-fixture').prop('checked'), true, "prop get" ); | ||
$('.prop-fixture').prop('checked',false); | ||
assert.equal($('.prop-fixture').prop('checked'), false, "prop set Passed!" ); | ||
assert.equal($('.prop-fixture').prop('checked'), false, "prop set" ); | ||
@@ -177,3 +177,3 @@ $('.prop-fixture').prop({ | ||
var testProps = [$('.prop-fixture').prop('checked'),$('.prop-fixture').prop('disabled')].join(' '); | ||
assert.equal(testProps, 'true true', "prop set multiple Passed!" ); | ||
assert.equal(testProps, 'true true', "prop set multiple" ); | ||
}); | ||
@@ -183,3 +183,3 @@ | ||
$('.attr-fixture').removeAttr('success'); | ||
assert.equal($('.attr-fixture').attr('success'), undefined, "removeAttr Passed!" ); | ||
assert.equal($('.attr-fixture').attr('success'), undefined, "removeAttr" ); | ||
}); | ||
@@ -199,9 +199,9 @@ | ||
$('.attr-fixture').removeClass('has-class'); | ||
assert.equal( $('.attr-fixture')[0].className, "attr-fixture has-class-two has-class-three", "removeClass Passed!" ); | ||
assert.equal( $('.attr-fixture')[0].className, "attr-fixture has-class-two has-class-three", "removeClass" ); | ||
$('.attr-fixture, .attr-fixture2').removeClass('has-class-three has-class-two'); | ||
assert.equal( $('.attr-fixture')[0].className, "attr-fixture", "removeClass Multiple Passed!" ); | ||
assert.equal( $('.attr-fixture2')[0].className, "attr-fixture2", "removeClass Multiple Passed!" ); | ||
assert.equal( $('.attr-fixture')[0].className, "attr-fixture", "removeClass Multiple" ); | ||
assert.equal( $('.attr-fixture2')[0].className, "attr-fixture2", "removeClass Multiple" ); | ||
$cf.removeClass(); | ||
assert.equal( $cf[0].className, '', 'removing all classes passed!' ); | ||
assert.equal( $cf[0].className, '', 'removing all classes' ); | ||
$cf.addClass('class-fixture'); | ||
@@ -215,3 +215,3 @@ | ||
$('.prop-fixture').prop('foo',123).removeProp('foo'); | ||
assert.equal($('.prop-fixture').prop('foo'), undefined, "removeProp Passed!" ); | ||
assert.equal($('.prop-fixture').prop('foo'), undefined, "removeProp" ); | ||
}); | ||
@@ -230,9 +230,9 @@ | ||
var hasClass = $('.attr-fixture').toggleClass('toggle-class-force',true).hasClass('toggle-class-force'); | ||
assert.equal(hasClass, true, "toggleClass (force add) Passed!" ); | ||
assert.equal(hasClass, true, "toggleClass (force add)" ); | ||
hasClass = $('.attr-fixture').toggleClass('toggle-class-force',false).hasClass('toggle-class-force'); | ||
assert.equal(hasClass, false, "toggleClass (force remove) Passed!" ); | ||
assert.equal(hasClass, false, "toggleClass (force remove)" ); | ||
var hasClass = $('.attr-fixture').toggleClass('toggle-class').hasClass('toggle-class'); | ||
assert.equal(hasClass, true, "toggleClass (add) Passed!" ); | ||
assert.equal(hasClass, true, "toggleClass (add)" ); | ||
var hasClass = $('.attr-fixture').toggleClass('toggle-class').hasClass('toggle-class'); | ||
assert.equal(hasClass, false, "toggleClass (remove) Passed!" ); | ||
assert.equal(hasClass, false, "toggleClass (remove)" ); | ||
var hasClass = $('.attr-fixture').toggleClass('foo$bar', true).toggleClass('foo$bar').hasClass('foo$bar'); | ||
@@ -246,16 +246,16 @@ assert.equal(hasClass, false, "toggleClass works with classes containing special characters" ); | ||
var addFixture = $('#id-fixture').add( $('.class-fixture') ); | ||
assert.equal(addFixture.__cash, true, "add Passed!" ); | ||
assert.equal(addFixture.length, 2, "add(one) Passed!" ); | ||
assert.equal(addFixture.__cash, true, "add" ); | ||
assert.equal(addFixture.length, 2, "add(one)" ); | ||
addFixture = $('#id-fixture').add( $('a').eq(0) ).add( $('a').eq(1) ); | ||
assert.equal(addFixture.length, 3, "add(two) Passed!" ); | ||
assert.equal(addFixture.length, 3, "add(two)" ); | ||
addFixture = $('#id-fixture').add( $('#qunit-fixture a') ).add( $('#qunit-fixture input') ); | ||
assert.equal(addFixture.length, 16, "add(collections) Passed!" ); | ||
assert.equal(addFixture.length, 16, "add(collections)" ); | ||
addFixture = $('#qunit-fixture a').first().add( $('#qunit-fixture a') ); | ||
assert.equal(addFixture.length, 5, "add(no duplicates) Passed!" ); | ||
assert.equal(addFixture.length, 5, "add(no duplicates)" ); | ||
addFixture = $('#id-fixture').add( "#qunit-fixture a" ); | ||
assert.equal(addFixture.length, 6, "add(allow selector string) Passed!" ); | ||
assert.equal(addFixture.length, 6, "add(allow selector string)" ); | ||
}); | ||
@@ -268,7 +268,7 @@ | ||
}); | ||
assert.equal(arrayFixture.length, 2, "each Passed!" ); | ||
assert.equal(arrayFixture.length, 2, "each" ); | ||
}); | ||
QUnit.test( "eq", function( assert ) { | ||
assert.equal($('#qunit-fixture div').eq(1)[0], $('#id-fixture')[0], "eq Passed!" ); | ||
assert.equal($('#qunit-fixture div').eq(1)[0], $('#id-fixture')[0], "eq" ); | ||
}); | ||
@@ -278,10 +278,10 @@ | ||
var arrayFixture = $('#qunit-fixture div').filter('.has-class'); | ||
assert.equal(arrayFixture.length, 1, "filter(selector) Passed!" ); | ||
assert.equal(arrayFixture.length, 1, "filter(selector)" ); | ||
arrayFixture = $('#qunit-fixture div').filter(function(i,e){ | ||
return $(e).hasClass('qsa-fixture'); | ||
}); | ||
assert.equal(arrayFixture.length, 2, "filter(fn) Passed!" ); | ||
assert.equal(arrayFixture.length, 2, "filter(fn)" ); | ||
arrayFixture = $('#qunit-fixture div').filter($('#qunit-fixture div').get(0)); | ||
assert.equal(arrayFixture.length, 1, "filter(element) Passed!" ); | ||
assert.equal(arrayFixture.length, 1, "filter(element)" ); | ||
}); | ||
@@ -291,3 +291,3 @@ | ||
var firstFixture = $('#qunit-fixture div').first(); | ||
assert.equal(firstFixture.hasClass('class-fixture'), true, "first Passed!" ); | ||
assert.equal(firstFixture.hasClass('class-fixture'), true, "first" ); | ||
}); | ||
@@ -297,3 +297,3 @@ | ||
var getFixture = $('#qunit-fixture div').get(1); | ||
assert.equal($(getFixture).attr('id'), 'id-fixture', "get Passed!" ); | ||
assert.equal($(getFixture).attr('id'), 'id-fixture', "get" ); | ||
@@ -306,5 +306,5 @@ var qsa = $('.qsa-fixture'); | ||
var indexFixture = $('.qsa-fixture').index(); | ||
assert.equal(indexFixture, 3, "index Passed!" ); | ||
assert.equal(indexFixture, 3, "index" ); | ||
var indexFixture = $('#qunit-fixture').children().index('.qsa-fixture'); | ||
assert.equal(indexFixture, 3, "index Passed!" ); | ||
assert.equal(indexFixture, 3, "index" ); | ||
}); | ||
@@ -314,3 +314,3 @@ | ||
var lastFixture = $('#qunit-fixture div').last(); | ||
assert.equal($(lastFixture).hasClass('attr-fixture2'), true, "last Passed!" ); | ||
assert.equal($(lastFixture).hasClass('attr-fixture2'), true, "last" ); | ||
}); | ||
@@ -320,3 +320,3 @@ | ||
var result = $('#id-fixture').map(function(i,e){ return document; }); | ||
assert.deepEqual(result[0], document, "map Passed!" ); | ||
assert.deepEqual(result[0], document, "map" ); | ||
}); | ||
@@ -327,4 +327,4 @@ | ||
var slice = qsa.slice(1); | ||
assert.deepEqual(slice.length, 1, "slice length Passed!" ); | ||
assert.deepEqual(slice[0], qsa[1], "slice element Passed!" ); | ||
assert.deepEqual(slice.length, 1, "slice length" ); | ||
assert.deepEqual(slice[0], qsa[1], "slice element" ); | ||
}); | ||
@@ -335,7 +335,7 @@ | ||
QUnit.test( "css", function( assert ) { | ||
assert.equal($('.css-fixture').css('height'), '50px', "css read Passed!" ); | ||
assert.equal($('.css-fixture').css('height'), '50px', "css read" ); | ||
$('.css-fixture').css('height','100px'); | ||
assert.equal($('.css-fixture').css('height'), '100px', "css write Passed!" ); | ||
assert.equal($('.css-fixture').css('height'), '100px', "css write" ); | ||
$('.css-fixture').css({height: '50px', width: '100px'}); | ||
assert.equal($('.css-fixture').css('width'), '100px', "css write many Passed!" ); | ||
assert.equal($('.css-fixture').css('width'), '100px', "css write many" ); | ||
}); | ||
@@ -346,16 +346,16 @@ | ||
QUnit.test( "data", function( assert ) { | ||
assert.deepEqual($('.attr-fixture').data(), {index: 5, 'index-other': 100}, "data read all Passed!" ); | ||
assert.equal($('.attr-fixture').data('index'), 5, "data read Passed!" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 100, "data read Passed!" ); | ||
assert.deepEqual($('.attr-fixture').data(), {index: 5, 'index-other': 100}, "data read all" ); | ||
assert.equal($('.attr-fixture').data('index'), 5, "data read" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 100, "data read" ); | ||
$('.attr-fixture').data('index',10); | ||
$('.attr-fixture').data('index-other',10); | ||
assert.equal($('.attr-fixture').data('index'), 10, "data set Passed!" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 10, "data set Passed!" ); | ||
assert.equal($('.attr-fixture').data('index'), 10, "data set" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 10, "data set" ); | ||
$('.attr-fixture').removeData('index'); | ||
assert.equal($('.attr-fixture').data('index'), 5, "data remove Passed!" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 10, "data remove Passed!" ); | ||
assert.equal($('.attr-fixture').data('index'), 5, "data remove" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 10, "data remove" ); | ||
$('.attr-fixture').data('index',10); | ||
$('.attr-fixture').removeData(); | ||
assert.equal($('.attr-fixture').data('index'), 5, "data remove all Passed!" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 100, "data remove all Passed!" ); | ||
assert.equal($('.attr-fixture').data('index'), 5, "data remove all" ); | ||
assert.equal($('.attr-fixture').data('index-other'), 100, "data remove all" ); | ||
}); | ||
@@ -366,35 +366,35 @@ | ||
QUnit.test( "height", function( assert ) { | ||
assert.equal($('.css-fixture').height(), 50, "height get Passed!" ); | ||
assert.equal($(window).height(), window.outerHeight, "(window) height get Passed!" ); | ||
assert.equal($('.css-fixture').height(), 50, "height get" ); | ||
assert.equal($(window).height(), window.outerHeight, "(window) height get" ); | ||
$('.css-fixture').height(200); | ||
assert.equal($('.css-fixture').height(), 200, "height set Passed!" ); | ||
assert.equal(Math.round($('.css-fixture').height()), 200, "height set" ); | ||
}); | ||
QUnit.test( "innerHeight", function( assert ) { | ||
assert.equal($('.css-fixture').innerHeight(), 90, "innerHeight Passed!" ); | ||
assert.equal($(window).innerHeight(), window.innerHeight, "(window) innerHeight Passed!" ); | ||
assert.equal($('.css-fixture').innerHeight(), 90, "innerHeight" ); | ||
assert.equal($(window).innerHeight(), window.innerHeight, "(window) innerHeight" ); | ||
}); | ||
QUnit.test( "outerHeight", function( assert ) { | ||
assert.equal($('.css-fixture').outerHeight(), 100, "outerHeight Passed!" ); | ||
assert.equal($(window).outerHeight(), window.outerHeight, "(window) outerHeight Passed!" ); | ||
assert.equal($('.css-fixture').outerHeight(true), 140, "outerHeight(margins) Passed!" ); | ||
assert.equal($('.css-fixture').outerHeight(), 100, "outerHeight" ); | ||
assert.equal($(window).outerHeight(), window.outerHeight, "(window) outerHeight" ); | ||
assert.equal($('.css-fixture').outerHeight(true), 140, "outerHeight(margins)" ); | ||
}); | ||
QUnit.test( "width", function( assert ) { | ||
assert.equal($('.css-fixture').width(), 50, "width get Passed!" ); | ||
assert.equal($(window).width(), window.outerWidth, "(window) width get Passed!" ); | ||
assert.equal($('.css-fixture').width(), 50, "width get" ); | ||
assert.equal($(window).width(), window.outerWidth, "(window) width get" ); | ||
$('.css-fixture').width(200); | ||
assert.equal($('.css-fixture').width(), 200, "width set Passed!" ); | ||
assert.equal($('.css-fixture').width(), 200, "width set" ); | ||
}); | ||
QUnit.test( "innerWidth", function( assert ) { | ||
assert.equal($('.css-fixture').innerWidth(), 90, "innerWidth Passed!" ); | ||
assert.equal($(window).innerWidth(), window.innerWidth, "(window) innerWidth Passed!" ); | ||
assert.equal($('.css-fixture').innerWidth(), 90, "innerWidth" ); | ||
assert.equal($(window).innerWidth(), window.innerWidth, "(window) innerWidth" ); | ||
}); | ||
QUnit.test( "outerWidth", function( assert ) { | ||
assert.equal($('.css-fixture').outerWidth(), 100, "outerWidth Passed!" ); | ||
assert.equal($(window).outerWidth(), window.outerWidth, "(window) outerWidth Passed!" ); | ||
assert.equal($('.css-fixture').outerWidth(true), 140, "outerWidth(margins) Passed!" ); | ||
assert.equal($('.css-fixture').outerWidth(), 100, "outerWidth" ); | ||
assert.equal($(window).outerWidth(), window.outerWidth, "(window) outerWidth" ); | ||
assert.equal($('.css-fixture').outerWidth(true), 140, "outerWidth(margins)" ); | ||
}); | ||
@@ -411,3 +411,3 @@ | ||
$('.event-fixture').trigger('click'); | ||
assert.equal($('.event-fixture')[0].textContent, 2, "on Passed!" ); | ||
assert.equal($('.event-fixture')[0].textContent, 2, "on" ); | ||
@@ -419,3 +419,3 @@ var j = 1; | ||
$('.event-fixture').trigger('foo').trigger('bar'); | ||
assert.equal(j, 3, "on multiple Passed!" ); | ||
assert.equal(j, 3, "on multiple" ); | ||
}); | ||
@@ -430,3 +430,3 @@ | ||
$('.delegate-trigger').trigger('click'); | ||
assert.equal(i, 2, "on(delegate) Passed!" ); | ||
assert.equal(i, 2, "on(delegate)" ); | ||
@@ -446,3 +446,3 @@ $('#qunit-fixture').off('click',delegateHandler); | ||
$('.event-fixture').trigger('foo.ns1.ns2').trigger('foo.ns1').trigger('foo.ns2'); | ||
assert.equal(i, 4, "on(namespaces) Passed!" ); | ||
assert.equal(i, 4, "on(namespaces)" ); | ||
}); | ||
@@ -458,3 +458,3 @@ | ||
$('.event-fixture').on('foo', handler).trigger('foo'); | ||
assert.equal(i, 2, "on(return false) Passed!" ); | ||
assert.equal(i, 2, "on(return false)" ); | ||
}); | ||
@@ -469,7 +469,7 @@ | ||
$('.event-fixture').trigger('click').trigger('click'); | ||
assert.equal(i, 2, "one Passed!" ); | ||
assert.equal(i, 2, "one" ); | ||
i = 1; | ||
$('.event-fixture').one('click', handler).off('click', handler).trigger('click'); | ||
assert.equal(i, 1, "one removal Passed!" ); | ||
assert.equal(i, 1, "one removal" ); | ||
}); | ||
@@ -487,3 +487,3 @@ | ||
$('.off-fixture').trigger('click'); | ||
assert.equal($('.off-fixture')[0].textContent, 2, "off Passed!" ); | ||
assert.equal($('.off-fixture')[0].textContent, 2, "off" ); | ||
@@ -493,3 +493,3 @@ $('.off-fixture').on('foo bar', handler); | ||
$('.off-fixture').trigger('foo').trigger('bar'); | ||
assert.equal($('.off-fixture')[0].textContent, 2, "off multiple Passed!" ); | ||
assert.equal($('.off-fixture')[0].textContent, 2, "off multiple" ); | ||
@@ -499,3 +499,3 @@ $('.off-fixture').on('foo bar', handler); | ||
$('.off-fixture').trigger('foo').trigger('bar'); | ||
assert.equal($('.off-fixture')[0].textContent, 2, "off all Passed!" ); | ||
assert.equal($('.off-fixture')[0].textContent, 2, "off all" ); | ||
}); | ||
@@ -514,3 +514,3 @@ | ||
$('.event-fixture').on('foo.ns1.ns2', handler).off('foo.ns3').trigger('foo').trigger('foo.ns1').trigger('foo.ns2').trigger('foo.ns3'); | ||
assert.equal(i, 4, "off(namespaces) Passed!" ); | ||
assert.equal(i, 4, "off(namespaces)" ); | ||
}); | ||
@@ -525,3 +525,3 @@ | ||
$('.trigger-fixture').trigger('click'); | ||
assert.equal($('.trigger-fixture')[0].textContent, 2, "trigger Passed!" ); | ||
assert.equal($('.trigger-fixture')[0].textContent, 2, "trigger" ); | ||
}); | ||
@@ -538,6 +538,6 @@ | ||
$('.trigger-data-fixture').trigger('custom', 1); | ||
assert.equal($('.trigger-data-fixture')[0].textContent, 2, "trigger(data) Passed!" ); | ||
assert.equal($('.trigger-data-fixture')[0].textContent, 2, "trigger(data)" ); | ||
$('.trigger-data-fixture').trigger('custom',123); | ||
assert.equal(data, 123, "trigger(data) argument Passed!" ); | ||
assert.equal(data, 123, "trigger(data) argument" ); | ||
}); | ||
@@ -552,3 +552,3 @@ | ||
$('.event-fixture').trigger('foo').trigger('foo.ns1').trigger('foo.ns2').trigger('foo.ns1.ns2'); | ||
assert.equal(namespaces[0] === '' && namespaces[1] === 'ns1' && namespaces[2] === 'ns2' && namespaces[3] === 'ns1.ns2', true, "off(namespaces) Passed!" ); | ||
assert.equal(namespaces[0] === '' && namespaces[1] === 'ns1' && namespaces[2] === 'ns2' && namespaces[3] === 'ns1.ns2', true, "off(namespaces)" ); | ||
}); | ||
@@ -562,3 +562,3 @@ | ||
$('.event-fixture').on('foo.ns1.ns2', handler).trigger('foo').trigger('foo.ns1').trigger('foo.ns2').trigger('foo.ns3').trigger('foo.ns1.ns3'); | ||
assert.equal(i, 4, "off(namespaces) Passed!" ); | ||
assert.equal(i, 4, "off(namespaces)" ); | ||
}); | ||
@@ -570,6 +570,6 @@ | ||
var data = $('.form-fixture').serialize(); | ||
assert.equal(data, "hidden=5&text=text&checkbox-yes=yes&radio=yes&select=selected&select-multiple=option-1&select-multiple=option-2", "serialize Passed!" ); | ||
assert.equal(data, "hidden=5&text=text&checkbox-yes=yes&radio=yes&select=selected&select-multiple=option-1&select-multiple=option-2", "serialize" ); | ||
data = $( ".form-fixture input, .form-fixture textarea, .form-fixture select" ).serialize(); | ||
assert.equal(data, "hidden=5&text=text&checkbox-yes=yes&radio=yes&select=selected&select-multiple=option-1&select-multiple=option-2", "serialize Passed!" ); | ||
assert.equal(data, "hidden=5&text=text&checkbox-yes=yes&radio=yes&select=selected&select-multiple=option-1&select-multiple=option-2", "serialize" ); | ||
}); | ||
@@ -579,21 +579,21 @@ | ||
var data = $('#qunit-fixture input[type=text]').serialize(); | ||
assert.equal(data, "text=text", "serialize elemnts passed!" ); | ||
assert.equal(data, "text=text", "serialize elemnts" ); | ||
}); | ||
QUnit.test( "val", function( assert ) { | ||
assert.equal($('#qunit-fixture input[type=text]').val(), "text", "val get Passed!" ); | ||
assert.equal($('#qunit-fixture input[type=text]').val(), "text", "val get" ); | ||
$('#qunit-fixture input[type=text]').val(0); | ||
assert.equal($('#qunit-fixture input[type=text]').val(), 0, "val set Passed!" ); | ||
assert.equal($('select[name=select]').val(), "selected", "val get select Passed!" ); | ||
assert.equal($('#qunit-fixture input[type=text]').val(), 0, "val set" ); | ||
assert.equal($('select[name=select]').val(), "selected", "val get select" ); | ||
$('select[name=select]').val('not-selected'); | ||
assert.equal($('select[name=select]').val(), "not-selected", "val set select Passed!" ); | ||
assert.deepEqual($('select[name=select-multiple]').val(), ['option-1', 'option-2'], "val get select multiple Passed!" ); | ||
assert.equal($('select[name=select]').val(), "not-selected", "val set select" ); | ||
assert.deepEqual($('select[name=select-multiple]').val(), ['option-1', 'option-2'], "val get select multiple" ); | ||
$('#qunit-fixture input[type=text]').val(null); | ||
$('select[name=select-multiple]').val(null); | ||
assert.deepEqual($('#qunit-fixture input[type=text]').val(), '', "val set to null Passed!" ); | ||
assert.deepEqual($('select[name=select-multiple]').val(), [], "val set to null Passed!" ); | ||
assert.deepEqual($('#qunit-fixture input[type=text]').val(), '', "val set to null" ); | ||
assert.deepEqual($('select[name=select-multiple]').val(), [], "val set to null" ); | ||
$('select[name=select-multiple]').val(['option-1']); | ||
assert.deepEqual($('select[name=select-multiple]').val(), ['option-1'], "val set 1 option in select multiple Passed!" ); | ||
assert.deepEqual($('select[name=select-multiple]').val(), ['option-1'], "val set 1 option in select multiple" ); | ||
$('select[name=select-multiple]').val(['option-1', 'option-2']); | ||
assert.deepEqual($('select[name=select-multiple]').val(), ['option-1', 'option-2'], "val set 2 options in select multiple Passed!" ); | ||
assert.deepEqual($('select[name=select-multiple]').val(), ['option-1', 'option-2'], "val set 2 options in select multiple" ); | ||
}); | ||
@@ -606,4 +606,4 @@ | ||
$('.anchor').after('<div class="test">'); | ||
assert.equal($('.anchor').prev ().length, 0, "after Passed!" ); | ||
assert.equal($('.anchor').siblings ().length, 1, "after Passed!" ); | ||
assert.equal($('.anchor').prev ().length, 0, "after" ); | ||
assert.equal($('.anchor').siblings ().length, 1, "after" ); | ||
}); | ||
@@ -614,4 +614,4 @@ | ||
$('.anchor').after('<div class="test">', '<div class="test">', '<div class="test">'); | ||
assert.equal($('.anchor').prev ().length, 0, "after(multi) Passed!" ); | ||
assert.equal($('.anchor').siblings ().length, 3, "after(multi) Passed!" ); | ||
assert.equal($('.anchor').prev ().length, 0, "after(multi)" ); | ||
assert.equal($('.anchor').siblings ().length, 3, "after(multi)" ); | ||
}); | ||
@@ -621,3 +621,4 @@ | ||
$('#qunit-fixture').append('<div class="test">'); | ||
assert.equal($('.test').length, 1, "append Passed!" ); | ||
$('#qunit-fixture').append(undefined); // It shouldn't throw | ||
assert.equal($('.test').length, 1, "append" ); | ||
}); | ||
@@ -627,3 +628,3 @@ | ||
$('#qunit-fixture').append('<div class="test">', '<div class="test">', '<div class="test">'); | ||
assert.equal($('.test').length, 3, "append(multi) Passed!" ); | ||
assert.equal($('.test').length, 3, "append(multi)" ); | ||
}); | ||
@@ -633,3 +634,3 @@ | ||
$('<div class="test">').appendTo('#qunit-fixture'); | ||
assert.equal($('.test').length, 1, "appendTo Passed!" ); | ||
assert.equal($('.test').length, 1, "appendTo" ); | ||
}); | ||
@@ -640,4 +641,4 @@ | ||
$('.anchor').before('<div class="test">'); | ||
assert.equal($('.anchor').next ().length, 0, "before Passed!" ); | ||
assert.equal($('.anchor').siblings ().length, 1, "before Passed!" ); | ||
assert.equal($('.anchor').next ().length, 0, "before" ); | ||
assert.equal($('.anchor').siblings ().length, 1, "before" ); | ||
}); | ||
@@ -648,8 +649,8 @@ | ||
$('.anchor').before('<div class="test">', '<div class="test">', '<div class="test">'); | ||
assert.equal($('.anchor').next ().length, 0, "before(multi) Passed!" ); | ||
assert.equal($('.anchor').siblings ().length, 3, "before(multi) Passed!" ); | ||
assert.equal($('.anchor').next ().length, 0, "before(multi)" ); | ||
assert.equal($('.anchor').siblings ().length, 3, "before(multi)" ); | ||
}); | ||
QUnit.test( "clone", function( assert ) { | ||
assert.equal($('.class-fixture').clone()[0].className, 'class-fixture', "clone Passed!" ); | ||
assert.equal($('.class-fixture').clone()[0].className, 'class-fixture', "clone" ); | ||
}); | ||
@@ -667,8 +668,8 @@ | ||
ele.detach(); | ||
assert.equal($('.class-fixture').length, 0, "detach Passed!" ); | ||
assert.equal(i, 2, "detach events Passed!" ); | ||
assert.equal($('.class-fixture').length, 0, "detach" ); | ||
assert.equal(i, 2, "detach events" ); | ||
}); | ||
QUnit.test( "empty", function( assert ) { | ||
assert.equal($('.form-fixture').empty().children().length, 0, "empty Passed!" ); | ||
assert.equal($('.form-fixture').empty().children().length, 0, "empty" ); | ||
}); | ||
@@ -678,3 +679,3 @@ | ||
$('.class-fixture').html('<div class="html-test">'); | ||
assert.equal($('.html-test').length, 1, "html Passed!" ); | ||
assert.equal($('.html-test').length, 1, "html" ); | ||
}); | ||
@@ -684,3 +685,3 @@ | ||
$('.class-fixture').html('test'); | ||
assert.equal($('.class-fixture')[0].innerHTML, 'test', "html string Passed!" ); | ||
assert.equal($('.class-fixture')[0].innerHTML, 'test', "html string" ); | ||
}); | ||
@@ -690,3 +691,3 @@ | ||
$('.class-fixture').html(0); | ||
assert.equal($('.class-fixture')[0].innerHTML, '0', "html numeric Passed!" ); | ||
assert.equal($('.class-fixture')[0].innerHTML, '0', "html numeric" ); | ||
}); | ||
@@ -696,3 +697,3 @@ | ||
$('<div class="test"></div>').insertAfter('input[type=hidden]'); | ||
assert.equal($('.test').index(), 1, "insertAfter Passed!" ); | ||
assert.equal($('.test').index(), 1, "insertAfter" ); | ||
}); | ||
@@ -702,3 +703,3 @@ | ||
$('<div class="test"></div>').insertBefore('input[type=hidden]'); | ||
assert.equal($('.test').index(), 0, "insertBefore Passed!" ); | ||
assert.equal($('.test').index(), 0, "insertBefore" ); | ||
}); | ||
@@ -708,3 +709,4 @@ | ||
$('.form-fixture').prepend('<div class="test"></div>'); | ||
assert.equal($('.test').index(), 0, "prepend Passed!" ); | ||
$('.form-fixture').prepend(undefined); // It shouldn't throw | ||
assert.equal($('.test').index(), 0, "prepend" ); | ||
}); | ||
@@ -714,3 +716,3 @@ | ||
$('.form-fixture').prepend('<div class="test"></div>', '<div class="test"></div>', '<div class="test"></div>'); | ||
assert.equal($('.test').length, 3, "prepend Passed!" ); | ||
assert.equal($('.test').length, 3, "prepend" ); | ||
}); | ||
@@ -720,3 +722,3 @@ | ||
$('<div class="test"></div>').prependTo('.form-fixture'); | ||
assert.equal($('.test').index(), 0, "prependTo Passed!" ); | ||
assert.equal($('.test').index(), 0, "prependTo" ); | ||
}); | ||
@@ -734,4 +736,4 @@ | ||
ele.remove(); | ||
assert.equal($('.class-fixture').length, 0, "remove Passed!" ); | ||
assert.equal(i, 1, "remove events Passed!" ); | ||
assert.equal($('.class-fixture').length, 0, "remove" ); | ||
assert.equal(i, 1, "remove events" ); | ||
}); | ||
@@ -743,3 +745,3 @@ | ||
$('.qsa-fixture').get ().forEach ( function ( ele ) { | ||
assert.equal($(ele)[0].outerHTML, html, "replaceAll Passed!" ); | ||
assert.equal($(ele)[0].outerHTML, html, "replaceAll" ); | ||
}); | ||
@@ -751,3 +753,3 @@ }); | ||
$('.class-fixture').replaceWith(html); | ||
assert.equal($('.class-fixture')[0].outerHTML, html, "replaceWith Passed!" ); | ||
assert.equal($('.class-fixture')[0].outerHTML, html, "replaceWith" ); | ||
}); | ||
@@ -757,5 +759,5 @@ | ||
$('.class-fixture').text('Text Content'); | ||
assert.equal($('.class-fixture')[0].textContent, "Text Content", "text Passed!" ); | ||
assert.equal($('.class-fixture')[0].textContent, "Text Content", "text" ); | ||
$('.class-fixture').text(0); | ||
assert.equal($('.class-fixture')[0].textContent, 0, "text Passed!" ); | ||
assert.equal($('.class-fixture')[0].textContent, 0, "text" ); | ||
}); | ||
@@ -767,3 +769,3 @@ | ||
$('#qunit-fixture').css('position', 'relative'); // An element is said to be positioned if it has a CSS position attribute of relative, absolute, or fixed | ||
assert.equal($('.class-fixture').offsetParent ()[0], $('#qunit-fixture')[0], "offsetParent Passed!" ); | ||
assert.equal($('.class-fixture').offsetParent ()[0], $('#qunit-fixture')[0], "offsetParent" ); | ||
}); | ||
@@ -774,3 +776,3 @@ | ||
$('.class-fixture').html(html); | ||
assert.deepEqual($('.offset-fixture').offset (), {top:200,left:100}, "offset Passed!" ); | ||
assert.deepEqual($('.offset-fixture').offset (), {top:200,left:100}, "offset" ); | ||
}); | ||
@@ -781,3 +783,3 @@ | ||
$('.class-fixture').html(html); | ||
assert.deepEqual($('.position-fixture').position (), {top:20,left:10}, "position Passed!" ); | ||
assert.deepEqual($('.position-fixture').position (), {top:20,left:10}, "position" ); | ||
}); | ||
@@ -788,44 +790,44 @@ | ||
QUnit.test( "children", function( assert ) { | ||
assert.equal($('#qunit-fixture').children().length, 15, "children Passed!" ); | ||
assert.equal($('#qunit-fixture').children('div').length, 6, "children(selector) Passed!" ); | ||
assert.equal($('#qunit-fixture').children().length, 15, "children" ); | ||
assert.equal($('#qunit-fixture').children('div').length, 6, "children(selector)" ); | ||
}); | ||
QUnit.test( "closest", function( assert ) { | ||
assert.equal($('input.prop-fixture').closest().length, 0, "closest Passed!" ); | ||
assert.equal($('input.prop-fixture').closest('div')[0].id, "qunit-fixture", "closest Passed!" ); | ||
assert.equal($('input.prop-fixture').closest().length, 0, "closest" ); | ||
assert.equal($('input.prop-fixture').closest('div')[0].id, "qunit-fixture", "closest" ); | ||
}); | ||
QUnit.test( "find", function( assert ) { | ||
assert.equal($('.form-fixture').find('input[type=hidden]').length, 1, "find Passed!" ); | ||
assert.equal($('.form-fixture').find('input[type=hidden]').length, 1, "find" ); | ||
}); | ||
QUnit.test( "has", function( assert ) { | ||
assert.equal($('.form-fixture').has('input').length, true, "has Passed!" ); | ||
assert.equal($('.form-fixture').has('input').length, true, "has" ); | ||
}); | ||
QUnit.test( "is", function( assert ) { | ||
assert.equal($('#id-fixture').is(), false, "is Passed!" ); | ||
assert.equal($('#id-fixture').is('div'), true, "is Passed!" ); | ||
assert.equal($('#id-fixture').is('#id-fixture'), true, "is Passed!" ); | ||
assert.equal($('#id-fixture').is($('#id-fixture')), true, "is Passed!" ); | ||
assert.equal($('#id-fixture').is($('div')), true, "is Passed!" ); | ||
assert.equal($('#id-fixture').is($('#class-fixture')), false, "is Passed!" ); | ||
assert.equal($('#id-fixture').is(), false, "is" ); | ||
assert.equal($('#id-fixture').is('div'), true, "is" ); | ||
assert.equal($('#id-fixture').is('#id-fixture'), true, "is" ); | ||
assert.equal($('#id-fixture').is($('#id-fixture')), true, "is" ); | ||
assert.equal($('#id-fixture').is($('div')), true, "is" ); | ||
assert.equal($('#id-fixture').is($('#class-fixture')), false, "is" ); | ||
}); | ||
QUnit.test( "next", function( assert ) { | ||
assert.equal($('.form-fixture input').next().val(), 'text', "next Passed!" ); | ||
assert.equal($('.form-fixture input').next().val(), 'text', "next" ); | ||
}); | ||
QUnit.test( "not", function( assert ) { | ||
assert.equal($('#qunit-fixture div').not('.qsa-fixture').length, 4, "not Passed!" ); | ||
assert.equal($('#qunit-fixture div').not('.qsa-fixture').length, 4, "not" ); | ||
}); | ||
QUnit.test( "parent", function( assert ) { | ||
assert.equal($('.qsa-fixture').parent()[0].id, 'qunit-fixture', "parent Passed!" ); | ||
assert.equal($('.qsa-fixture').parent().length, 1, "parent Passed!" ); | ||
assert.equal($('.qsa-fixture').parent()[0].id, 'qunit-fixture', "parent" ); | ||
assert.equal($('.qsa-fixture').parent().length, 1, "parent" ); | ||
}); | ||
QUnit.test( "parents", function( assert ) { | ||
assert.equal($('.form-fixture input').parents().length, 4, "parents Passed!" ); | ||
assert.equal($('.form-fixture input').parents('div, form').length, 2, "parents(selector) Passed!" ); | ||
assert.equal($('.form-fixture input').parents().length, 4, "parents" ); | ||
assert.equal($('.form-fixture input').parents('div, form').length, 2, "parents(selector)" ); | ||
assert.equal($('.form-fixture input').parents()[ $('.form-fixture input').parents().length-1 ], document.body.parentNode, "last element in collection is <html>" ); | ||
@@ -835,7 +837,7 @@ }); | ||
QUnit.test( "prev", function( assert ) { | ||
assert.equal($('.form-fixture input[type=text]').prev().val(), 5, "prev Passed!" ); | ||
assert.equal($('.form-fixture input[type=text]').prev().val(), 5, "prev" ); | ||
}); | ||
QUnit.test( "siblings", function( assert ) { | ||
assert.equal($('#id-fixture').siblings().length, 14, "siblings Passed!" ); | ||
assert.equal($('#id-fixture').siblings().length, 14, "siblings" ); | ||
}); | ||
@@ -846,3 +848,3 @@ | ||
QUnit.test( "$.camelCase", function( assert ) { | ||
assert.equal($.camelCase('border-width'), 'borderWidth', "$.camelCase Passed!" ); | ||
assert.equal($.camelCase('border-width'), 'borderWidth', "$.camelCase" ); | ||
}); | ||
@@ -855,3 +857,3 @@ | ||
}); | ||
assert.equal(test, 3, "$.each Passed!" ); | ||
assert.equal(test, 3, "$.each" ); | ||
}); | ||
@@ -862,35 +864,35 @@ | ||
$.extend(orig,test); | ||
assert.equal(orig.count, 3, "$.extend Passed!" ); | ||
assert.equal(orig.count, 3, "$.extend" ); | ||
}); | ||
QUnit.test( "$.isArray", function( assert ) { | ||
assert.equal($.isArray(true), false, "$.isArray boolean Passed!" ); | ||
assert.equal($.isArray(123), false, "$.isArray number Passed!" ); | ||
assert.equal($.isArray('foo'), false, "$.isArray string Passed!" ); | ||
assert.equal($.isArray([1,2,3]), true, "$.isArray array Passed!" ); | ||
assert.equal($.isArray(function(){}), false, "$.isArray function Passed!" ); | ||
assert.equal($.isArray(true), false, "$.isArray boolean" ); | ||
assert.equal($.isArray(123), false, "$.isArray number" ); | ||
assert.equal($.isArray('foo'), false, "$.isArray string" ); | ||
assert.equal($.isArray([1,2,3]), true, "$.isArray array" ); | ||
assert.equal($.isArray(function(){}), false, "$.isArray function" ); | ||
}); | ||
QUnit.test( "$.isFunction", function( assert ) { | ||
assert.equal($.isFunction(true), false, "$.isFunction boolean Passed!" ); | ||
assert.equal($.isFunction(123), false, "$.isFunction number Passed!" ); | ||
assert.equal($.isFunction('foo'), false, "$.isFunction string Passed!" ); | ||
assert.equal($.isFunction([1,2,3]), false, "$.isFunction array Passed!" ); | ||
assert.equal($.isFunction(function(){}), true, "$.isFunction function Passed!" ); | ||
assert.equal($.isFunction(true), false, "$.isFunction boolean" ); | ||
assert.equal($.isFunction(123), false, "$.isFunction number" ); | ||
assert.equal($.isFunction('foo'), false, "$.isFunction string" ); | ||
assert.equal($.isFunction([1,2,3]), false, "$.isFunction array" ); | ||
assert.equal($.isFunction(function(){}), true, "$.isFunction function" ); | ||
}); | ||
QUnit.test( "$.isNumeric", function( assert ) { | ||
assert.equal($.isNumeric(true), false, "$.isNumeric boolean Passed!" ); | ||
assert.equal($.isNumeric(123), true, "$.isNumeric number Passed!" ); | ||
assert.equal($.isNumeric('foo'), false, "$.isNumeric string Passed!" ); | ||
assert.equal($.isNumeric([1,2,3]), false, "$.isNumeric array Passed!" ); | ||
assert.equal($.isNumeric(function(){}), false, "$.isNumeric function Passed!" ); | ||
assert.equal($.isNumeric(true), false, "$.isNumeric boolean" ); | ||
assert.equal($.isNumeric(123), true, "$.isNumeric number" ); | ||
assert.equal($.isNumeric('foo'), false, "$.isNumeric string" ); | ||
assert.equal($.isNumeric([1,2,3]), false, "$.isNumeric array" ); | ||
assert.equal($.isNumeric(function(){}), false, "$.isNumeric function" ); | ||
}); | ||
QUnit.test( "$.isString", function( assert ) { | ||
assert.equal($.isString(true), false, "$.isString boolean Passed!" ); | ||
assert.equal($.isString(123), false, "$.isString number Passed!" ); | ||
assert.equal($.isString('foo'), true, "$.isString string Passed!" ); | ||
assert.equal($.isString([1,2,3]), false, "$.isString array Passed!" ); | ||
assert.equal($.isString(function(){}), false, "$.isString function Passed!" ); | ||
assert.equal($.isString(true), false, "$.isString boolean" ); | ||
assert.equal($.isString(123), false, "$.isString number" ); | ||
assert.equal($.isString('foo'), true, "$.isString string" ); | ||
assert.equal($.isString([1,2,3]), false, "$.isString array" ); | ||
assert.equal($.isString(function(){}), false, "$.isString function" ); | ||
}); | ||
@@ -900,8 +902,23 @@ | ||
var test = $('<div class="test">')[0], selector = ".test"; | ||
assert.equal($.matches(test,selector), true, "$.matches Passed!" ); | ||
assert.equal($.matches(test,selector), true, "$.matches" ); | ||
}); | ||
QUnit.test( "$.parseHTML", function( assert ) { | ||
assert.equal($.parseHTML('<a></a>')[0].outerHTML, '<a></a>' , "$.parseHTML Passed!" ); | ||
assert.equal($.parseHTML('<a></a>')[0].outerHTML, '<a></a>' , "$.parseHTML" ); | ||
assert.equal($.parseHTML('<a>')[0].outerHTML,'<a></a>', '$.parseHTML supports malformed single tags'); | ||
assert.equal($.parseHTML('<tbody>')[0].outerHTML,'<tbody></tbody>', '$.parseHTML supports simple <tbody>'); | ||
assert.equal($.parseHTML('<thead>')[0].outerHTML,'<thead></thead>', '$.parseHTML supports simple <thead>'); | ||
assert.equal($.parseHTML('<tfoot>')[0].outerHTML,'<tfoot></tfoot>', '$.parseHTML supports simple <tfoot>'); | ||
assert.equal($.parseHTML('<tr>')[0].outerHTML,'<tr></tr>', '$.parseHTML supports simple <tr>'); | ||
assert.equal($.parseHTML('<td>')[0].outerHTML,'<td></td>', '$.parseHTML supports simple <td>'); | ||
assert.equal($.parseHTML('<th>')[0].outerHTML,'<th></th>', '$.parseHTML supports simple <th>'); | ||
assert.equal($.parseHTML('<tbody><tr></tr></tbody>')[0].outerHTML,'<tbody><tr></tr></tbody>', '$.parseHTML supports advanced <tbody>'); | ||
assert.equal($.parseHTML('<thead><tr></tr></thead>')[0].outerHTML,'<thead><tr></tr></thead>', '$.parseHTML supports advanced <thead>'); | ||
assert.equal($.parseHTML('<tfoot><tr></tr></tfoot>')[0].outerHTML,'<tfoot><tr></tr></tfoot>', '$.parseHTML supports advanced <tfoot>'); | ||
assert.equal($.parseHTML('<tr><td></td></tr>')[0].outerHTML,'<tr><td></td></tr>', '$.parseHTML supports advanced <tr>'); | ||
assert.equal($.parseHTML('<td><p></p></td>')[0].outerHTML,'<td><p></p></td>', '$.parseHTML supports advanced <td>'); | ||
assert.equal($.parseHTML('<th><p></p></th>')[0].outerHTML,'<th><p></p></th>', '$.parseHTML supports advanced <th>'); | ||
var span = $('<span>CONTENT</span>'); | ||
@@ -913,5 +930,5 @@ $('<div></div>'); | ||
QUnit.test( "$.prefixedProp", function( assert ) { | ||
assert.equal($.prefixedProp( 'foo-bar' ), undefined, "$.prefixedProp returns undefined Passed!" ); | ||
assert.equal($.prefixedProp( '--foo-bar' ), '--foo-bar', "$.prefixedProp works with css variables Passed!" ); | ||
assert.equal($.prefixedProp( 'width' ), 'width', "$.prefixedProp works with basic css properties Passed!" ); | ||
assert.equal($.prefixedProp( 'foo-bar' ), undefined, "$.prefixedProp returns undefined" ); | ||
assert.equal($.prefixedProp( '--foo-bar' ), '--foo-bar', "$.prefixedProp works with css variables" ); | ||
assert.equal($.prefixedProp( 'width' ), 'width', "$.prefixedProp works with basic css properties" ); | ||
}); | ||
@@ -921,3 +938,3 @@ | ||
var test = [ $("#id-fixture")[0], $("#id-fixture")[0] ]; | ||
assert.equal($.unique( test ).length, 1, "$.unique Passed!" ); | ||
assert.equal($.unique( test ).length, 1, "$.unique" ); | ||
}); |
Sorry, the diff of this file is not supported yet
623096
4509