Skip to content

Instantly share code, notes, and snippets.

@jamesjtong
Created April 9, 2014 13:42
Show Gist options
  • Save jamesjtong/10272048 to your computer and use it in GitHub Desktop.
Save jamesjtong/10272048 to your computer and use it in GitHub Desktop.
firefox not hoisting ngActiveResource properly?
angular.module('ActiveResource').provider('ARMixin', function () {
this.$get = function () {
return function (receiver, giver, excludeFunctions) {
function mixinProp() {
if (!receiver.hasOwnProperty(i)) {
(function () {
var local;
Object.defineProperty(receiver, i, {
enumerable: true,
get: function () {
return local;
},
set: function (val) {
local = val;
}
});
}());
receiver[i] = giver[i];
}
}
if (giver.constructor.name == 'Function') {
giver = new giver();
}
for (var i in giver) {
if (excludeFunctions) {
if (typeof giver[i] !== 'function') {
mixinProp();
}
} else {
mixinProp();
}
// function mixinProp() {
// if (!receiver.hasOwnProperty(i)) {
// (function () {
// var local;
// Object.defineProperty(receiver, i, {
// enumerable: true,
// get: function () {
// return local;
// },
// set: function (val) {
// local = val;
// }
// });
// }());
// receiver[i] = giver[i];
// }
// }
}
return receiver;
};
};
});
angular.module('ActiveResource').provider('ARMixin', function () {
this.$get = function () {
return function (receiver, giver, excludeFunctions) {
if (giver.constructor.name == 'Function') {
giver = new giver();
}
for (var i in giver) {
if (excludeFunctions) {
if (typeof giver[i] !== 'function') {
mixinProp();
}
} else {
mixinProp();
}
function mixinProp() {
if (!receiver.hasOwnProperty(i)) {
(function () {
var local;
Object.defineProperty(receiver, i, {
enumerable: true,
get: function () {
return local;
},
set: function (val) {
local = val;
}
});
}());
receiver[i] = giver[i];
}
}
}
return receiver;
};
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment