From d3ff222a04d56de13cce780c6ed3d39a39ffadda Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 19 May 2012 13:16:04 +0400 Subject: [PATCH] Ox.$: return undefined for non-existing attributes (like jQuery); fix a wrong 'this' reference --- source/Ox/js/DOM.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/Ox/js/DOM.js b/source/Ox/js/DOM.js index 308e0cd0..230a64bf 100644 --- a/source/Ox/js/DOM.js +++ b/source/Ox/js/DOM.js @@ -67,7 +67,7 @@ Ox.$ Generic HTML element, mimics jQuery > Ox.$('
').attr({id: 'red'}).attr('id') 'red' > Ox.$('
').attr({id: 'red'}).removeAttr('id').attr('id') - '' + void 0 > Ox.$('
').css({color: 'red'}).css('color') 'red' > Ox.$('
').html('red').html() @@ -133,6 +133,9 @@ Ox.$ = Ox.element = function(val) { var ret, that = this; if (arguments.length == 1 && Ox.isString(arguments[0])) { ret = this[0].getAttribute(arguments[0]); + if (ret === null) { + ret = void 0; + } } else { Ox.forEach(Ox.makeObject(arguments), function(v, k) { that[0].setAttribute(k, v); @@ -254,8 +257,9 @@ Ox.$ = Ox.element = function(val) { key The attribute @*/ removeAttr: function() { + var that = this; Ox.makeArray(arguments[0]).forEach(function(key) { - this[0].removeAttribute(key); + that[0].removeAttribute(key); }); return this; },