Permalink
Browse files

Funny:

For Internet Explorer:
[undefined].length -> 0

For all other browsers:
[undefined].length -> 1
  • Loading branch information...
Szaby Grünwald
Szaby Grünwald committed Dec 7, 2011
1 parent fb2a23f commit 010b95ef26505c6f3853f109352e6a95a439fe33
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/Entity.js
View
@@ -63,7 +63,7 @@ VIE.prototype.Entity = function(attrs, opts) {
attr = mapAttributeNS(attr, self.vie.namespaces);
var value = Backbone.Model.prototype.get.call(this, attr);
value = (_.isArray(value))? value : [ value ];
-
+
value = _.map(value, function(v) {
if (v !== undefined && attr === '@type' && self.vie.types.get(v)) {
return self.vie.types.get(v);
@@ -73,6 +73,9 @@ VIE.prototype.Entity = function(attrs, opts) {
return v;
}
}, this);
+ if(value.length === 0) {
+ return undefined;
+ }
// if there is only one element, just return that one
value = (value.length === 1)? value[0] : value;
return value;

0 comments on commit 010b95e

Please sign in to comment.