-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule node-overload
added at
f51beb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,27 @@ | ||
|
||
|
||
// hack hack hack | ||
var DOMPatch = exports.DOM = function DOMPatch(elem, rules) { | ||
var that = this; | ||
rules = rules || {}; | ||
this.__children = []; | ||
for(var key in elem) { | ||
if (rules.hasOwnProperty(key)) { | ||
rules[key](this, key, elem); | ||
|
||
} else if (key === "childNodes") { | ||
this.__defineGetter__(key, function () { | ||
return that.__children; | ||
}); | ||
var children = elem.childNodes; | ||
for(var n=0,l=children.length;n<l;n++) { | ||
this.__children.push(new DOMPatch(children[n], rules)); | ||
} | ||
|
||
} else if (key && key[0] !== "_") { | ||
if (typeof elem[key] === 'function') | ||
this[key] = (function (k) { | ||
return function () { | ||
return elem[k].apply(elem, arguments); | ||
}; | ||
})(key); | ||
else | ||
this.__defineSetter__(key, (function (k) { | ||
return function (val) { | ||
return elem[k] = val; | ||
}; | ||
})(key)); | ||
this.__defineGetter__(key, (function (k) { | ||
return function () { | ||
return elem[k]; | ||
}; | ||
})(key)); | ||
} | ||
} | ||
}; | ||
module.exports = function (overload) { | ||
|
||
var result = {}; | ||
|
||
// hack hack hack | ||
var patch = result.nodeName = function (elem) { | ||
return overload.Watchable(function get(info) { | ||
var key = info.property; | ||
if (key === "nodeName") { | ||
return elem.nodeName.toLowerCase(); // thats the reason | ||
|
||
} else if (key === "childNodes") { | ||
var res = []; | ||
for(var i=0,l=elem.childNodes.length;i<l;i++) | ||
res.push(patch(elem.childNodes[i])); | ||
return res; | ||
|
||
exports.nodeName = function (elem) { | ||
return new DOMPatch(elem, { | ||
nodeName : function (that, k, e) { | ||
that.__defineGetter__(k, function () { | ||
return e.nodeName.toLowerCase(); // thats the reason | ||
}); | ||
}, | ||
}); | ||
} else return elem[key]; | ||
}); | ||
}; | ||
|
||
return result; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters