Skip to content

Commit

Permalink
ensure getPrototypeOf is defined in old browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
scambra committed Jun 14, 2013
1 parent 0168b2f commit 5d8c249
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/active_scaffold.js.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<% case ActiveScaffold.js_framework %>
<% when :jquery %>
<% require_asset "getprototypeof" %>
<% if Jquery::Rails.const_defined? 'JQUERY_UI_VERSION' %>
<% require_asset "jquery-ui" %>
<% require_asset "jquery-ui-timepicker-addon" %>
Expand Down
12 changes: 12 additions & 0 deletions vendor/assets/javascripts/getprototypeof.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if ( typeof Object.getPrototypeOf !== "function" ) {
if ( typeof "test".__proto__ === "object" ) {
Object.getPrototypeOf = function(object){
return object.__proto__;
};
} else {
Object.getPrototypeOf = function(object){
// May break if the constructor has been tampered with
return object.constructor.prototype;
};
}
}

0 comments on commit 5d8c249

Please sign in to comment.