Ox.$: return undefined for non-existing attributes (like jQuery); fix a wrong 'this' reference
This commit is contained in:
parent
f793245e2e
commit
d3ff222a04
1 changed files with 6 additions and 2 deletions
|
@ -67,7 +67,7 @@ Ox.$ <f> Generic HTML element, mimics jQuery
|
||||||
> Ox.$('<div>').attr({id: 'red'}).attr('id')
|
> Ox.$('<div>').attr({id: 'red'}).attr('id')
|
||||||
'red'
|
'red'
|
||||||
> Ox.$('<div>').attr({id: 'red'}).removeAttr('id').attr('id')
|
> Ox.$('<div>').attr({id: 'red'}).removeAttr('id').attr('id')
|
||||||
''
|
void 0
|
||||||
> Ox.$('<div>').css({color: 'red'}).css('color')
|
> Ox.$('<div>').css({color: 'red'}).css('color')
|
||||||
'red'
|
'red'
|
||||||
> Ox.$('<div>').html('red').html()
|
> Ox.$('<div>').html('red').html()
|
||||||
|
@ -133,6 +133,9 @@ Ox.$ = Ox.element = function(val) {
|
||||||
var ret, that = this;
|
var ret, that = this;
|
||||||
if (arguments.length == 1 && Ox.isString(arguments[0])) {
|
if (arguments.length == 1 && Ox.isString(arguments[0])) {
|
||||||
ret = this[0].getAttribute(arguments[0]);
|
ret = this[0].getAttribute(arguments[0]);
|
||||||
|
if (ret === null) {
|
||||||
|
ret = void 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Ox.forEach(Ox.makeObject(arguments), function(v, k) {
|
Ox.forEach(Ox.makeObject(arguments), function(v, k) {
|
||||||
that[0].setAttribute(k, v);
|
that[0].setAttribute(k, v);
|
||||||
|
@ -254,8 +257,9 @@ Ox.$ = Ox.element = function(val) {
|
||||||
key <s> The attribute
|
key <s> The attribute
|
||||||
@*/
|
@*/
|
||||||
removeAttr: function() {
|
removeAttr: function() {
|
||||||
|
var that = this;
|
||||||
Ox.makeArray(arguments[0]).forEach(function(key) {
|
Ox.makeArray(arguments[0]).forEach(function(key) {
|
||||||
this[0].removeAttribute(key);
|
that[0].removeAttribute(key);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue