Created
April 9, 2014 13:42
-
-
Save jamesjtong/10272048 to your computer and use it in GitHub Desktop.
firefox not hoisting ngActiveResource properly?
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
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; | |
}; | |
}; | |
}); |
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
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