Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 1.4.1

  • Loading branch information...
commit d2643f686f626d310404c57ebef128ad196b62b4 1 parent 876321b
@glebm authored
View
2  README.md
@@ -69,6 +69,8 @@ You will need node and coffee-script installed:
* npm install -g coffee-script
# Changelog / What's new
+v1.4.1:
+* IE7 $b(nodes...) fix
v1.4:
View
2  build.sh
@@ -8,7 +8,7 @@ coffee -bp dombrew.coffee > dombrew.js
echo "Building dombrew.min.js..."
#java -jar compiler.jar --js dombrew.js > dombrew.min.js
-uglify-js -nc --unsafe dombrew.js > dombrew.min.js
+uglifyjs -nc --unsafe dombrew.js > dombrew.min.js
echo "Building dombrew.min.js.gz to check the size..."
gzip -c9 dombrew.min.js > dombrew.min.js.gz
View
17 dombrew.coffee
@@ -29,7 +29,7 @@ class Node
pos = elemType.length
classes = attr['class']
for piece in pieces
- (elem[pos] == '#') && (attr['id'] = piece) || classes.push(piece)
+ (elem.charAt(pos) == '#') && (attr['id'] = piece) || classes.push(piece)
pos += piece.length + 1
delete attr['class'] unless attr['class'].length
elemType
@@ -38,8 +38,13 @@ class Node
# joinValues('a') => 'a'
joinValues = (value) ->
return value if typeof value != 'object'
- (piece for piece in value when piece).join(' ')
- return
+ r = []
+ i = -1
+ length = value.length
+ while (++i < length)
+ r.push(value[i]) if value[i]
+ r.join(' ')
+
constructor: (elem, attr, more) ->
attr ||= {}
@@ -93,9 +98,9 @@ Node::asHTML = Node::html
@DOMBrew = D = ->
a = arguments
# If passed an array, wrap it in a DocumentFragment
- if (typeof a[0])[0] == 'o' && 'splice' of a[0] # $b([nodes...]) form
+ if (typeof a[0] == 'object') && ('splice' of a[0]) # $b([nodes...]) form
nodes = a[0]
- else if a.length > 1 && (typeof a[1])[0] == 'o' && ('_brew' of a[1]) # $b(nodes...) form
+ else if a.length > 1 && (typeof a[1] == 'object') && ('_brew' of a[1]) # $b(nodes...) form
nodes = a
if nodes
frag = d.createDocumentFragment()
@@ -103,7 +108,7 @@ Node::asHTML = Node::html
a = [frag]
new Node(a[0], a[1], a[2])
-D.VERSION = D.version = '1.4'
+D.VERSION = D.version = '1.4.1'
# innerText fix (Firefox)
if (H = HTMLElement) && !H::innerText && H::__defineGetter__ && H::__defineSetter__
View
28 dombrew.js
@@ -35,7 +35,7 @@ Node = (function() {
classes = attr['class'];
for (_i = 0, _len = pieces.length; _i < _len; _i++) {
piece = pieces[_i];
- (elem[pos] === '#') && (attr['id'] = piece) || classes.push(piece);
+ (elem.charAt(pos) === '#') && (attr['id'] = piece) || classes.push(piece);
pos += piece.length + 1;
}
if (!attr['class'].length) {
@@ -44,21 +44,19 @@ Node = (function() {
return elemType;
};
joinValues = function(value) {
- var piece;
+ var i, length, r;
if (typeof value !== 'object') {
return value;
}
- ((function() {
- var _i, _len, _results;
- _results = [];
- for (_i = 0, _len = value.length; _i < _len; _i++) {
- piece = value[_i];
- if (piece) {
- _results.push(piece);
- }
+ r = [];
+ i = -1;
+ length = value.length;
+ while (++i < length) {
+ if (value[i]) {
+ r.push(value[i]);
}
- return _results;
- })()).join(' ');
+ }
+ return r.join(' ');
};
function Node(elem, attr, more) {
var css, name, prop, s, value;
@@ -134,9 +132,9 @@ Node.prototype.asHTML = Node.prototype.html;
this.DOMBrew = D = function() {
var a, frag, node, nodes, _i, _len;
a = arguments;
- if ((typeof a[0])[0] === 'o' && 'splice' in a[0]) {
+ if ((typeof a[0] === 'object') && ('splice' in a[0])) {
nodes = a[0];
- } else if (a.length > 1 && (typeof a[1])[0] === 'o' && ('_brew' in a[1])) {
+ } else if (a.length > 1 && (typeof a[1] === 'object') && ('_brew' in a[1])) {
nodes = a;
}
if (nodes) {
@@ -149,7 +147,7 @@ this.DOMBrew = D = function() {
}
return new Node(a[0], a[1], a[2]);
};
-D.VERSION = D.version = '1.4';
+D.VERSION = D.version = '1.4.1';
if ((H = HTMLElement) && !H.prototype.innerText && H.prototype.__defineGetter__ && H.prototype.__defineSetter__) {
H.prototype.__defineGetter__("innerText", function() {
return this.textContent;
View
2  dombrew.min.js
@@ -1 +1 @@
-var D,H,Node,d;d=document,Node=function(){function f(a,f,g){var h,i,j,k,l;f||(f={});if(a.nodeType)this.e=a;else{if(a==="text"){this.e=d.createTextNode(f);return}typeof f=="string"&&(g||(g={}),g.text=f,f=g),this.e=d.createElement(e(a,f)),f["class"]&&(this.e.className=c(f["class"]))&&delete f["class"],f.text&&(this.e.innerText=c(f.text))&&delete f.text,f.html&&(this.e.innerHTML=c(f.html))&&delete f.html;if(f.css&&(k=this.e.style)&&(h=f.css)&&delete f.css)for(j in h)l=h[j],k[j]=l;b(f);for(i in f)l=f[i],this.e.setAttribute(i,l)}}var a,b,c,e;f.prototype._brew=1,b=function(a){var b,c,d,e;for(b in a){c=a[b];if(typeof a[b]=="object"){for(d in c)e=c[d],a[b+"-"+d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()]=e;delete a[b]}}},a=/[.#]/,e=function(b,c){var d,e,f,g,h,i,j;if(!a.test(b))return b;c["class"]||(c["class"]=[]),typeof c["class"]=="string"&&(c["class"]=[c["class"]]),a.test(b[0])&&(b="div"+b),g=b.split(a),e=g.shift(),h=e.length,d=c["class"];for(i=0,j=g.length;i<j;i++)f=g[i],b[h]==="#"&&(c.id=f)||d.push(f),h+=f.length+1;c["class"].length||delete c["class"];return e},c=function(a){var b;if(typeof a!="object")return a;(function(){var c,d,e;e=[];for(c=0,d=a.length;c<d;c++)b=a[c],b&&e.push(b);return e})().join(" ")},f.prototype.append=function(){var a,b,c,d;a=arguments,"splice"in a[0]&&(a=a[0]);for(c=0,d=a.length;c<d;c++)b=a[c],"_brew"in b&&(b=b.dom()),this.e.appendChild(b);return this},f.prototype.prepend=function(){var a,b,c,d;a=arguments,"splice"in a[0]&&(a=a[0]);for(c=0,d=a.length;c<d;c++)b=a[c],"_brew"in b&&(b=b.dom()),this.e.insertBefore(b,this.e.firstChild);return this},f.prototype.dom=function(){return this.e},f.prototype.html=function(){var a;a=d.createElement("div"),a.appendChild(this.e);return a.innerHTML};return f}(),Node.prototype.asDOM=Node.prototype.dom,Node.prototype.asHTML=Node.prototype.html,this.DOMBrew=D=function(){var a,b,c,e,f,g;a=arguments,(typeof a[0])[0]==="o"&&"splice"in a[0]?e=a[0]:a.length>1&&(typeof a[1])[0]==="o"&&"_brew"in a[1]&&(e=a);if(e){b=d.createDocumentFragment();for(f=0,g=e.length;f<g;f++)c=e[f],b.appendChild(c.e);a=[b]}return new Node(a[0],a[1],a[2])},D.VERSION=D.version="1.4",(H=HTMLElement)&&!H.prototype.innerText&&H.prototype.__defineGetter__&&H.prototype.__defineSetter__&&(H.prototype.__defineGetter__("innerText",function(){return this.textContent}),H.prototype.__defineSetter__("innerText",function(a){return this.textContent=a}))
+var D,H,Node,d;d=document,Node=function(){function f(a,f,g){var h,i,j,k,l;f||(f={});if(a.nodeType)this.e=a;else{if(a==="text"){this.e=d.createTextNode(f);return}typeof f=="string"&&(g||(g={}),g.text=f,f=g),this.e=d.createElement(e(a,f)),f["class"]&&(this.e.className=c(f["class"]))&&delete f["class"],f.text&&(this.e.innerText=c(f.text))&&delete f.text,f.html&&(this.e.innerHTML=c(f.html))&&delete f.html;if(f.css&&(k=this.e.style)&&(h=f.css)&&delete f.css)for(j in h)l=h[j],k[j]=l;b(f);for(i in f)l=f[i],this.e.setAttribute(i,l)}}var a,b,c,e;f.prototype._brew=1,b=function(a){var b,c,d,e;for(b in a){c=a[b];if(typeof a[b]=="object"){for(d in c)e=c[d],a[b+"-"+d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()]=e;delete a[b]}}},a=/[.#]/,e=function(b,c){var d,e,f,g,h,i,j;if(!a.test(b))return b;c["class"]||(c["class"]=[]),typeof c["class"]=="string"&&(c["class"]=[c["class"]]),a.test(b[0])&&(b="div"+b),g=b.split(a),e=g.shift(),h=e.length,d=c["class"];for(i=0,j=g.length;i<j;i++)f=g[i],b.charAt(h)==="#"&&(c.id=f)||d.push(f),h+=f.length+1;c["class"].length||delete c["class"];return e},c=function(a){var b,c,d;if(typeof a!="object")return a;d=[],b=-1,c=a.length;while(++b<c)a[b]&&d.push(a[b]);return d.join(" ")},f.prototype.append=function(){var a,b,c,d;a=arguments,"splice"in a[0]&&(a=a[0]);for(c=0,d=a.length;c<d;c++)b=a[c],"_brew"in b&&(b=b.dom()),this.e.appendChild(b);return this},f.prototype.prepend=function(){var a,b,c,d;a=arguments,"splice"in a[0]&&(a=a[0]);for(c=0,d=a.length;c<d;c++)b=a[c],"_brew"in b&&(b=b.dom()),this.e.insertBefore(b,this.e.firstChild);return this},f.prototype.dom=function(){return this.e},f.prototype.html=function(){var a;a=d.createElement("div"),a.appendChild(this.e);return a.innerHTML};return f}(),Node.prototype.asDOM=Node.prototype.dom,Node.prototype.asHTML=Node.prototype.html,this.DOMBrew=D=function(){var a,b,c,e,f,g;a=arguments,typeof a[0]=="object"&&"splice"in a[0]?e=a[0]:a.length>1&&typeof a[1]=="object"&&"_brew"in a[1]&&(e=a);if(e){b=d.createDocumentFragment();for(f=0,g=e.length;f<g;f++)c=e[f],b.appendChild(c.e);a=[b]}return new Node(a[0],a[1],a[2])},D.VERSION=D.version="1.4.1",(H=HTMLElement)&&!H.prototype.innerText&&H.prototype.__defineGetter__&&H.prototype.__defineSetter__&&(H.prototype.__defineGetter__("innerText",function(){return this.textContent}),H.prototype.__defineSetter__("innerText",function(a){return this.textContent=a}))
Please sign in to comment.
Something went wrong with that request. Please try again.