elements-lite
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -0,1 +1,28 @@ | ||
/* | ||
* template: | ||
* https://github.com/Shopify/liquid/wiki/Liquid-for-Designers | ||
* https://github.com/paularmstrong/swig | ||
* http://jade-lang.com/reference/#plaintext | ||
* https://github.com/slim-template/slim | ||
* https://docs.djangoproject.com/en/1.6/topics/templates/ | ||
* http://bits.shutterstock.com/2013/03/07/mustache-vs-swig-templating-shootout/ | ||
* http://paularmstrong.github.io/node-templates/benchmarks.html | ||
* http://garann.github.io/template-chooser/ | ||
* http://engineering.linkedin.com/frontend/client-side-templating-throwdown-mustache-handlebars-dustjs-and-more | ||
* https://github.com/joyent/node/wiki/modules#templating | ||
* | ||
* | ||
* i18n: | ||
* http://slexaxton.github.io/Jed/ | ||
* | ||
* plural: | ||
* http://stackoverflow.com/questions/1353408/messageformat-in-javascript-parameters-in-localized-ui-strings | ||
* https://docs.google.com/presentation/d/1ZyN8-0VXmod5hbHveq-M1AeQ61Ga3BmVuahZjbmbBxo/pub?start=false&loop=false&delayms=3000#slide=id.g1bc43a82_2_83 | ||
* https://gist.github.com/kjantzer/4957176 | ||
* | ||
* Backbone is event-driven, not callback driven framework | ||
*/ | ||
Notes | ||
@@ -2,0 +29,0 @@ ----- |
@@ -5,9 +5,12 @@ | ||
/* | ||
* @version 0.1.16 | ||
* @date 2014-03-21 | ||
* @author Lauri Rooden <lauri@rooden.ee> | ||
* @license MIT License | ||
* @version 0.1.17 | ||
* @date 2014-03-24 | ||
* @stability 1 - Experimental | ||
* @author Lauri Rooden <lauri@rooden.ee> | ||
* @license MIT License | ||
*/ | ||
/* TODO: find ways for automated testing | ||
@@ -118,3 +121,3 @@ * http://www.browserscope.org/user/tests/howto | ||
proto.after = function(e, before) { | ||
e.parentNode.append(this, before ? e : e.nextSibling) | ||
proto.append.call(e.parentNode, this, before ? e : e.nextSibling) | ||
return this | ||
@@ -124,3 +127,6 @@ } | ||
proto.to = function(e, before) { | ||
e.append(this, before) | ||
/* | ||
* call append from proto so it works with DocumentFragment | ||
*/ | ||
proto.append.call(e, this, before) | ||
return this | ||
@@ -225,3 +231,19 @@ } | ||
/* | ||
* In Safari 2.x, innerText functions properly only | ||
* if an element is neither hidden (via style.display == "none") | ||
* nor orphaned from the document. | ||
* Otherwise, innerText results in an empty string. | ||
* | ||
* textContent is suported from IE9 | ||
*/ | ||
proto.text = function(newText) { | ||
var t = this | ||
, attr = "textContent" in t ? "textContent" : "innerText" | ||
return arguments.length ? (t[attr] = newText) : t[attr] | ||
} | ||
/* | ||
* Expose slow find for testing | ||
@@ -228,0 +250,0 @@ * |
@@ -1,3 +0,3 @@ | ||
!function(f,p){function q(a){for(var b=[],c=a.length;c--;)b[c]=a[c];return b}function g(){}function h(a){var b=p.createDocumentFragment(),c=b,e=[-1];a.replace(m,function(a,b,l,f,k){if(a){console.log("arguments",arguments);for(var d,g=b.length;g<=e[0];)e.shift(),c=c.plugin?c.plugin.done():c.parentNode;l?d=h.plugins[l]?(new h.plugins[l](c,f,k)).el:El.text(a):(d=El(f,k),k&&"="==k.charAt(0)&&console.log("bind",k.slice(1)));d&&(console.log("el",d),!d.plugin&&d.append.call(c,d),1==d.nodeType&&(c=d,e.unshift(g)))}return""}); | ||
console.log("str",a);a=b.childNodes;return 1==a.length?a[0]:q(a)}function n(){return this}function e(a,b,c){this.name=b;this.parent=a;this.el=El("div");this.el.plugin=this;return this}var m=/^([ \t]*)(\:\w+)?[ \t]*((?:=(["'\/])(?:\\.|.)*?\4|[-\w\:.#\[\]]+)+)[ \t]*(.*)$/gm;h.re=m;e.prototype={cloneNode:n,set:n,done:function(){El.cache(this.name,this.el.firstChild);this.el.plugin=null;return this.parent}};h.plugins={":html":function(a,b,c){a.innerHTML=El.text(b.slice(2).join(" "));return el},":template":e, | ||
":if":function(a,b,c){return new g(b,a)},":for":function(a,b,c){return new g(b,a)}};f.haml=h;f.render=function(a,b,c){b=El.get(a);(new e(a)).el.append(El.haml(b.innerHTML)).plugin.done();b.kill()}}(this.El||this,this.document); | ||
!function(n,r){function s(a){for(var b=[],c=a.length;c--;)b[c]=a[c];return b}function p(){}function f(a){function b(a,c,g,l,h,e){for(h=c.length;h<=k[0];)k.shift(),d=d.plugin?d.plugin.done():d.parentNode;g?f.plugins[l]?(d=(new f.plugins[l](d,e)).el,k.unshift(h)):d.append(El.text(a)):(d=El(l).to(d),k.unshift(h),e&&(">"==e.charAt(0)?(c+" "+e.slice(1)).replace(m,b):"="==e.charAt(0)?d.set({"data-bind":e.slice(1)}):d.append(e.replace(/\\([=>:])/g,"$1"))))}var c=r.createDocumentFragment(),d=c,k=[-1];a.replace(m, | ||
b);a=c.childNodes;return 1==a.length?a[0]:s(a)}function q(){return this}function g(a,b){this.name=b;this.parent=a;this.el=El("div");this.el.plugin=this;return this}var m=/^([ \t]*)(\:?)((?:(["'\/])(?:\\.|.)*?\4|[-\w\:.#\[\]=])+)[ \t]*(.*)$/gm;f.re=m;g.prototype={cloneNode:q,set:q,done:function(){El.cache(this.name,this.el.firstChild);this.el.plugin=null;return this.parent}};f.plugins={html:function(a,b,c){a.innerHTML=El.text(b.slice(2).join(" "));return el},template:g,"if":function(a,b,c){return new p(b, | ||
a)},"for":function(a,b,c){return new p(b,a)}};n.haml=f;n.render=function(a,b,c){b=El.get(a);(new g(a)).el.append(El.haml(b.innerHTML)).plugin.done();b.kill()}}(window.El||this,window.document); |
98
haml.js
@@ -5,4 +5,4 @@ | ||
/* | ||
* @version 0.1.16 | ||
* @date 2014-03-21 | ||
* @version 0.1.17 | ||
* @date 2014-03-24 | ||
* @author Lauri Rooden <lauri@rooden.ee> | ||
@@ -15,28 +15,3 @@ * @license MIT License | ||
!function(root, doc) { | ||
/* | ||
* template: | ||
* https://github.com/Shopify/liquid/wiki/Liquid-for-Designers | ||
* https://github.com/paularmstrong/swig | ||
* http://jade-lang.com/reference/#plaintext | ||
* https://github.com/slim-template/slim | ||
* https://docs.djangoproject.com/en/1.6/topics/templates/ | ||
* http://bits.shutterstock.com/2013/03/07/mustache-vs-swig-templating-shootout/ | ||
* http://paularmstrong.github.io/node-templates/benchmarks.html | ||
* http://garann.github.io/template-chooser/ | ||
* http://engineering.linkedin.com/frontend/client-side-templating-throwdown-mustache-handlebars-dustjs-and-more | ||
* https://github.com/joyent/node/wiki/modules#templating | ||
* | ||
* | ||
* i18n: | ||
* http://slexaxton.github.io/Jed/ | ||
* | ||
* plural: | ||
* http://stackoverflow.com/questions/1353408/messageformat-in-javascript-parameters-in-localized-ui-strings | ||
* https://docs.google.com/presentation/d/1ZyN8-0VXmod5hbHveq-M1AeQ61Ga3BmVuahZjbmbBxo/pub?start=false&loop=false&delayms=3000#slide=id.g1bc43a82_2_83 | ||
* https://gist.github.com/kjantzer/4957176 | ||
* | ||
* Backbone is event-driven, not callback driven framework | ||
*/ | ||
function to_array(a) { | ||
@@ -49,3 +24,3 @@ for (var b=[], c=a.length; c--;) b[c] = a[c] | ||
var hamlRe = /^([ \t]*)(\:\w+)?[ \t]*((?:=(["'\/])(?:\\.|.)*?\4|[-\w\:.#\[\]]+)+)[ \t]*(.*)$/gm | ||
var hamlRe = /^([ \t]*)(\:?)((?:(["'\/])(?:\\.|.)*?\4|[-\w\:.#\[\]=])+)[ \t]*(.*)$/gm | ||
@@ -59,42 +34,27 @@ | ||
str.replace(hamlRe, function(all, indent, plugin, name, text) { | ||
if (all) { | ||
console.log("arguments", arguments) | ||
function work(all, indent, plugin, name, q, text) { | ||
for (var i = indent.length; i <= stack[0]; ) { | ||
stack.shift() | ||
parent = (parent.plugin) ? parent.plugin.done() : parent.parentNode | ||
} | ||
for (var el, i = indent.length; i <= stack[0]; ) { | ||
stack.shift() | ||
parent = (parent.plugin) ? parent.plugin.done() : parent.parentNode | ||
if (plugin) { | ||
if (haml.plugins[name]) { | ||
parent = (new haml.plugins[name](parent, text)).el | ||
stack.unshift(i) | ||
} | ||
if (plugin) { | ||
if (haml.plugins[plugin]) { | ||
el = (new haml.plugins[plugin](parent, name, text)).el | ||
} | ||
else { | ||
el = El.text( all ) | ||
} | ||
} else { | ||
el = El(name, text) | ||
if (text) { | ||
if (text.charAt(0) == "=") { | ||
console.log("bind", text.slice(1)) | ||
} else { | ||
//el.append( text.replace(/'/g,"\\'") ) | ||
} | ||
} | ||
else { | ||
parent.append(El.text( all )) | ||
} | ||
if (el) { | ||
console.log("el", el) | ||
!el.plugin && el.append.call(parent, el) | ||
if (el.nodeType == 1) { | ||
parent = el | ||
stack.unshift(i) | ||
} | ||
} else { | ||
parent = El(name).to(parent) | ||
stack.unshift(i) | ||
if (text) { | ||
if (text.charAt(0)==">") (indent +" "+ text.slice(1)).replace(hamlRe, work) | ||
else if (text.charAt(0)=="=") parent.set({"data-bind": text.slice(1)}) | ||
else parent.append(text.replace(/\\([=>:])/g, "$1")) | ||
} | ||
} | ||
return "" | ||
}) | ||
//console.log("root",root) | ||
console.log("str",str) | ||
} | ||
str.replace(hamlRe, work) | ||
i = root.childNodes | ||
@@ -106,3 +66,3 @@ return i.length == 1 ? i[0] : to_array(i) | ||
function This() { return this } | ||
function template(parent, name, text) { | ||
function template(parent, name) { | ||
var t = this | ||
@@ -131,3 +91,3 @@ t.name = name | ||
haml.plugins = { | ||
":html": function(parent, name, text) { | ||
"html": function(parent, name, text) { | ||
parent.innerHTML = El.text(name.slice(2).join(" ")) | ||
@@ -149,7 +109,7 @@ return el | ||
*/ | ||
":template": template, | ||
":if": function(parent, name, text) { | ||
"template": template, | ||
"if": function(parent, name, text) { | ||
return new forEach(name, parent) | ||
}, | ||
":for": function(parent, name, text) { | ||
"for": function(parent, name, text) { | ||
return new forEach(name, parent) | ||
@@ -166,4 +126,4 @@ } | ||
} | ||
}(this.El || this, this.document) | ||
}(window.El || this, window.document) | ||
12
min.js
@@ -1,6 +0,6 @@ | ||
!function(m,f,g){function e(a,b){var d,c={};a=a.replace(n,function(a,b,d,e,f){c["."==b?(b="class",c[b]&&(d=c[b]+" "+d),b):"#"==b?"id":d]=(f?e.slice(1,-1):e)||d;return""})||"div";d=(h[a]||(h[a]=f.createElement(a))).cloneNode(!0).set(c);return k[a]&&k[a](d,b)||d.set(b)}function l(a,b,d){if(a)for(d in b=e[g],b)a[d]=b[d];return a}var h={},k={},c=(m.HTMLElement||m.Element||e)[g],n=/([.#:[])([-\w]+)(?:=((["'\/])(?:\\.|.)*?\4|[-\w]+)])?]?/g;c.append=function(a,b){if(a){if("string"==typeof a||"number"==typeof a)a= | ||
e.text(a);else if(!("nodeType"in a)&&"length"in a){for(var d=a.length,c=0,g=f.createDocumentFragment();c<d;)this.append.call(g,a[c++]);a=g}a.nodeType&&this.insertBefore(a,(!0===b?this.firstChild:"number"==typeof b?this.childNodes[0>b?this.childNodes.length-b-2:b]:b)||null);a.append_hook&&a.append_hook()}return this};c.after=function(a,b){a.parentNode.append(this,b?a:a.nextSibling);return this};c.to=function(a,b){a.append(this,b);return this};c.hasClass=function(a){return RegExp("\\b"+a+"\\b").test(this.className)}; | ||
c.addClass=function(a){this.className+=""==this.className?a:this.hasClass(a)?"":" "+a;return this};c.rmClass=function(a){this.className=(" "+this.className+" ").replace(" "+a+" "," ").trim();return this};c.toggleClass=function(a,b){1==arguments.length&&(b=!this.hasClass(a));this[b?"addClass":"rmClass"](a);return b};c.empty=function(){for(var a;a=this.firstChild;)this.kill.call(a);return this};c.kill=function(){this.parentNode&&this.parentNode.removeChild(this);Event.removeAll&&Event.removeAll(this); | ||
this.kill_hook&&this.kill_hook();this.empty&&this.empty();return this};c.on=function(a,b){Event.add(this,a,b);return this};c.non=function(a,b){Event.remove(this,a,b);return this};c.set=function(a){var b=typeof a,d;if(a)if("string"==b||"number"==b||a.nodeType||"length"in a)this.append(a);else for(b in a)d=a[b],"class"==b?this.addClass(d):"string"==typeof d?(this.setAttribute(b,d),"name"==b&&"\v"=="v"&&this.mergeAttributes(f.createElement("<INPUT name='"+b+"'/>"),!1)):d?this[b]=d:this.removeAttribute(b); | ||
return this};c._find=function(a){var b=0,d=["_"];a=a.replace(n,function(a,b,c,e){d.push("."==b?"(' '+_.className+' ').indexOf(' "+c+" ')>-1":"#"==b?"_.id=='"+c+"'":"_.getAttribute('"+c+"')"+(e?"=='"+e+"'":""));return""})||"*";for(var c=this.getElementsByTagName(a),e=Function("_","return "+d.join("&&"));a=c[b++];)if(e(a))return a.to?a:l(a)};c.find=f.querySelector?function(a){return this.querySelector(a)}:c._find;if(c===e[g]){var p=f.createElement;f.createElement=function(a){return l(p(a))};l(f.body)}e[g]= | ||
c;e.get=function(a){"string"==typeof a&&(a=f.getElementById(a));return a&&a.to?a:l(a)};e.cache=function(a,b,c){h[a]="string"==typeof b?e(b):b;c&&(k[a]=c)};e.cache.el=h;e.cache.fn=k;e.text=function(a){return f.createTextNode(a)};m.El=e}(window,document,"prototype"); | ||
!function(m,e,g){function d(a,b){var f,c={};a=a.replace(n,function(a,b,f,d,e){c["."==b?(b="class",c[b]&&(f=c[b]+" "+f),b):"#"==b?"id":f]=(e?d.slice(1,-1):d)||f;return""})||"div";f=(h[a]||(h[a]=e.createElement(a))).cloneNode(!0).set(c);return k[a]&&k[a](f,b)||f.set(b)}function l(a,b,f){if(a)for(f in b=d[g],b)a[f]=b[f];return a}var h={},k={},c=(m.HTMLElement||m.Element||d)[g],n=/([.#:[])([-\w]+)(?:=((["'\/])(?:\\.|.)*?\4|[-\w]+)])?]?/g;c.append=function(a,b){if(a){if("string"==typeof a||"number"==typeof a)a= | ||
d.text(a);else if(!("nodeType"in a)&&"length"in a){for(var f=a.length,c=0,g=e.createDocumentFragment();c<f;)this.append.call(g,a[c++]);a=g}a.nodeType&&this.insertBefore(a,(!0===b?this.firstChild:"number"==typeof b?this.childNodes[0>b?this.childNodes.length-b-2:b]:b)||null);a.append_hook&&a.append_hook()}return this};c.after=function(a,b){c.append.call(a.parentNode,this,b?a:a.nextSibling);return this};c.to=function(a,b){c.append.call(a,this,b);return this};c.hasClass=function(a){return RegExp("\\b"+ | ||
a+"\\b").test(this.className)};c.addClass=function(a){this.className+=""==this.className?a:this.hasClass(a)?"":" "+a;return this};c.rmClass=function(a){this.className=(" "+this.className+" ").replace(" "+a+" "," ").trim();return this};c.toggleClass=function(a,b){1==arguments.length&&(b=!this.hasClass(a));this[b?"addClass":"rmClass"](a);return b};c.empty=function(){for(var a;a=this.firstChild;)this.kill.call(a);return this};c.kill=function(){this.parentNode&&this.parentNode.removeChild(this);Event.removeAll&& | ||
Event.removeAll(this);this.kill_hook&&this.kill_hook();this.empty&&this.empty();return this};c.on=function(a,b){Event.add(this,a,b);return this};c.non=function(a,b){Event.remove(this,a,b);return this};c.set=function(a){var b=typeof a,c;if(a)if("string"==b||"number"==b||a.nodeType||"length"in a)this.append(a);else for(b in a)c=a[b],"class"==b?this.addClass(c):"string"==typeof c?(this.setAttribute(b,c),"name"==b&&"\v"=="v"&&this.mergeAttributes(e.createElement("<INPUT name='"+b+"'/>"),!1)):c?this[b]= | ||
c:this.removeAttribute(b);return this};c.text=function(a){var b="textContent"in this?"textContent":"innerText";return arguments.length?this[b]=a:this[b]};c._find=function(a){var b=0,c=["_"];a=a.replace(n,function(a,b,d,e){c.push("."==b?"(' '+_.className+' ').indexOf(' "+d+" ')>-1":"#"==b?"_.id=='"+d+"'":"_.getAttribute('"+d+"')"+(e?"=='"+e+"'":""));return""})||"*";for(var d=this.getElementsByTagName(a),e=Function("_","return "+c.join("&&"));a=d[b++];)if(e(a))return a.to?a:l(a)};c.find=e.querySelector? | ||
function(a){return this.querySelector(a)}:c._find;if(c===d[g]){var p=e.createElement;e.createElement=function(a){return l(p(a))};l(e.body)}d[g]=c;d.get=function(a){"string"==typeof a&&(a=e.getElementById(a));return a&&a.to?a:l(a)};d.cache=function(a,b,c){h[a]="string"==typeof b?d(b):b;c&&(k[a]=c)};d.cache.el=h;d.cache.fn=k;d.text=function(a){return e.createTextNode(a)};m.El=d}(window,document,"prototype"); |
{ | ||
"name": "elements-lite", | ||
"version": "0.1.16", | ||
"stability": 2, | ||
"version": "0.1.17", | ||
"stability": 1, | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Lauri Rooden <lauri@rooden.ee>", |
@@ -11,5 +11,5 @@ [1]: https://secure.travis-ci.org/litejs/elements-lite.png | ||
@version 0.1.16 | ||
@date 2014-03-21 | ||
@stability 2 - Unstable | ||
@version 0.1.17 | ||
@date 2014-03-24 | ||
@stability 1 - Experimental | ||
@@ -20,2 +20,3 @@ | ||
Syntax follows CSS Selectors where possible. | ||
@@ -27,2 +28,4 @@ Usage | ||
### Create elements one by one | ||
```javascript | ||
@@ -55,3 +58,3 @@ El("div", "test").to(document.body) | ||
- [GitHub repo][] | ||
- [npm module][] | ||
- [npm package][] | ||
@@ -58,0 +61,0 @@ |
@@ -5,3 +5,3 @@ | ||
/* | ||
* @version 0.1.16 | ||
* @version 0.1.17 | ||
* @author Lauri Rooden <lauri@rooden.ee> | ||
@@ -8,0 +8,0 @@ * @license MIT License |
@@ -6,28 +6,17 @@ global.Event = global.Event || {} | ||
var getString = (function() { | ||
var DIV = document.createElement("div"); | ||
function getString(node) { | ||
if ('outerHTML' in node) | ||
return node.outerHTML.toLowerCase().trim(); | ||
if (DIV.__fake) { | ||
return function(node) { | ||
return node.toString() | ||
} | ||
} | ||
var div = document.createElement("div"); | ||
div.appendChild(node.cloneNode(true)); | ||
return div.innerHTML; | ||
} | ||
if ('outerHTML' in DIV) | ||
return function(node) { | ||
return node.outerHTML.toLowerCase().trim(); | ||
}; | ||
return function(node) { | ||
var div = document.createElement("div"); | ||
div.appendChild(node.cloneNode(true)); | ||
return div.innerHTML; | ||
}; | ||
var el, h1, h2, h3, h4, select | ||
})(); | ||
require("testman"). | ||
var el, h1, h2, h3, h4, select | ||
require("testman") | ||
.describe("El"). | ||
describe("El"). | ||
it ("should build elements"). | ||
@@ -47,30 +36,3 @@ run(function(){ | ||
equal(getString(h4), "<h4></h4>"). | ||
equal(getString(el.append(h2)), "<div><h2></h2></div>"). | ||
anyOf(getString(h2.append(select)), [ '<h2><select id="id2" disabled="disabled" class="cl2"></select></h2>' | ||
, '<h2><select disabled="disabled" class="cl2" id="id2"></select></h2>' | ||
, '<h2><select id="id2" class="cl2" disabled="disabled"></select></h2>' | ||
, '<h2><select class=cl2 id=id2 disabled></select></h2>' | ||
, '<h2><select id=id2 class=cl2 disabled></select></h2>' | ||
]). | ||
equal(el.find("#id2"), select). | ||
equal(el.find(".cl2"), select). | ||
equal(el.find("#id2.cl2"), select). | ||
equal(el.find(".cl2#id2"), select). | ||
equal(el.find("select"), select). | ||
equal(el.find("select#id2"), select). | ||
equal(el.find("select.cl2"), select). | ||
equal(el.find("select#id2.cl2"), select). | ||
equal(el.find("select.cl2#id2"), select). | ||
equal(el.find("SELECT"), select). | ||
equal(el.find("SELECT#id2"), select). | ||
equal(el.find("SELECT.cl2"), select). | ||
equal(el.find("SELECT#id2.cl2"), select). | ||
equal(el.find("SELECT.cl2#id2"), select). | ||
equal(el.find("h2"), h2). | ||
equal(!!el.find(".cl3"), false). | ||
equal(select.kill(), select). | ||
equal(getString(El("")), "<div></div>"). | ||
@@ -124,2 +86,103 @@ equal(getString(El("div")), "<div></div>"). | ||
]). | ||
it ("has kill() and empty() methods"). | ||
equal(select.kill(), select). | ||
equal(h2.innerHTML, ""). | ||
equal(el.empty(), el). | ||
equal(el.innerHTML, ""). | ||
it ("set childs"). | ||
equal(getString(el.append(h2)), "<div><h2></h2></div>"). | ||
equal(getString(el.append(h1, h2)), "<div><h1></h1><h2></h2></div>"). | ||
equal(getString(h4.after(h2)), "<h4></h4>"). | ||
equal(getString(el), "<div><h1></h1><h2></h2><h4></h4></div>"). | ||
equal(getString(h3.after(h4, true)), "<h3></h3>"). | ||
equal(getString(el), "<div><h1></h1><h2></h2><h3></h3><h4></h4></div>"). | ||
equal(getString(h3.to(el, h4)), "<h3></h3>"). | ||
equal(getString(el), "<div><h1></h1><h2></h2><h3></h3><h4></h4></div>"). | ||
equal(getString(h1.append([h2, h3])), "<h1><h2></h2><h3></h3></h1>"). | ||
equal(getString(el), "<div><h1><h2></h2><h3></h3></h1><h4></h4></div>"). | ||
anyOf(getString(select.to(h2)), [ '<select id="id2" disabled="disabled" class="cl2"></select>' | ||
, '<select disabled="disabled" class="cl2" id="id2"></select>' | ||
, '<select id="id2" class="cl2" disabled="disabled"></select>' | ||
, '<select class=cl2 id=id2 disabled></select>' | ||
, '<select id=id2 class=cl2 disabled></select>' | ||
]). | ||
it ("find childs"). | ||
equal(el.find("#id2"), select). | ||
equal(el.find(".cl2"), select). | ||
equal(el.find("#id2.cl2"), select). | ||
equal(el.find(".cl2#id2"), select). | ||
equal(el.find("select"), select). | ||
equal(el.find("select#id2"), select). | ||
equal(el.find("select.cl2"), select). | ||
equal(el.find("select#id2.cl2"), select). | ||
equal(el.find("select.cl2#id2"), select). | ||
equal(el.find("SELECT"), select). | ||
equal(el.find("SELECT#id2"), select). | ||
equal(el.find("SELECT.cl2"), select). | ||
equal(el.find("SELECT#id2.cl2"), select). | ||
equal(el.find("SELECT.cl2#id2"), select). | ||
equal(el.find("h2"), h2). | ||
equal(!!el.find(".cl3"), false). | ||
it ("supports boolean attributes"). | ||
equal(getString(El("input:selected")), '<input selected="selected">'). | ||
it ("has text() method"). | ||
equal(el.text(), ""). | ||
equal(el.text("hello"), "hello"). | ||
equal(el.text(), "hello"). | ||
it ("has class methods"). | ||
equal(el.className, ""). | ||
equal(el.hasClass("c1"), false). | ||
equal(el.hasClass("c2"), false). | ||
equal(el.hasClass("c3"), false). | ||
equal(el.addClass("c1"), el). | ||
equal(el.hasClass("c1"), true). | ||
equal(el.hasClass("c2"), false). | ||
equal(el.hasClass("c3"), false). | ||
equal(el.addClass("c2"), el). | ||
equal(el.hasClass("c1"), true). | ||
equal(el.hasClass("c2"), true). | ||
equal(el.hasClass("c3"), false). | ||
equal(el.rmClass("c3"), el). | ||
equal(el.hasClass("c1"), true). | ||
equal(el.hasClass("c2"), true). | ||
equal(el.hasClass("c3"), false). | ||
equal(el.rmClass("c2"), el). | ||
equal(el.hasClass("c1"), true). | ||
equal(el.hasClass("c2"), false). | ||
equal(el.hasClass("c3"), false). | ||
equal(el.rmClass("c1"), el). | ||
equal(el.hasClass("c1"), false). | ||
equal(el.hasClass("c2"), false). | ||
equal(el.hasClass("c3"), false). | ||
equal(el.className, ""). | ||
equal(el.toggleClass("c1"), true). | ||
equal(el.hasClass("c1"), true). | ||
equal(el.toggleClass("c1", true), true). | ||
equal(el.hasClass("c1"), true). | ||
equal(el.toggleClass("c1"), false). | ||
equal(el.hasClass("c1"), false). | ||
equal(el.toggleClass("c1", false), false). | ||
equal(el.hasClass("c1"), false). | ||
equal(el.className, ""). | ||
done() | ||
@@ -126,0 +189,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66729
1489
65
1