| Issue 1852: | Prototyping Object breaks API | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.
1. Add Object.prototype.newFunction = function() { } to a page with the API
and load the page in a browser.
In Chrome the first error occurs in XX._initProtos() in a (program) script
(maybe a Chrome issue?), then an exception of "TypeError: Object
newFunction has no method 'branch'" in main.js. The map doesn't load.
In IE the first error is "'__type' is null or not an object" in main.js,
followed by "Object doesn't support this property of method" in
mod_jslinker.js, and finally "Object doesn't support this property of
method" in main.js. The map doesn't load.
If Firefox the only error is "XX.__type has no properties" in main.js. The
map loads however.
What version of the API are you using?
(In the JS API, you can tell this by checking the value of G_API_VERSION.)
2.104, 2.140, 2.176, 2.180
What operating system and browser are you using?
Windows XP, Chrome 3.0.195.27, IE 8.0.6001.18702, Firefox 2.0.0.20
Jan 11, 2010
#1
[email protected]
Status:
WontFix
Dec 2, 2010
This issue reoccurs in version 3 javascript API: <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> I use the following utility methods: Object.prototype.isArray = function(){ return this.constructor === Array.prototype.constructor; }; Object.prototype.getNextSibling = function(){ var endBrother = this.nextSibling; while(endBrother.nodeType !== 1){ endBrother = endBrother.nextSibling; } return endBrother; }; Object.prototype.getFirstChild = function(){ var firstChild = this.firstChild; while(firstChild.nodeType !== 1){ firstChild = firstChild.nextSibling; } return firstChild; }; any one of which (or any other custom method added to Object) inhibits Google Maps completely. Error is thrown on trying to execute: var canvas = document.getElementById('map_canvas');//OK - element exists var map = new google.maps.Map(canvas);//throws error regardless of whether the methods are defined before or after the Google maps script tag (see above). FF 3.6.12 (Win 2000): Error: Invalid value: [object Object] (Invalid value for property <isArray>: function () { return this.constructor === Array.prototype.constructor; }) Source File: http://maps.gstatic.com/intl/en_us/mapfiles/api-3/3/2/main.js Line: 16 Opera 10.63 (Win 2000): Uncaught exception: Error: Invalid value: [object Object] (Invalid value for property <isArray>: function(){ return this.constructor === Array.prototype.constructor; }) Error thrown at line 1, column 39 in aa(a): throw a; called from line 16, column 194 in <anonymous function>(): aa(ia("Invalid value: "+(arguments[0]+(" ("+(c[kc](" | ")+")"))))); called from line 25, column 1796 in <anonymous function>(c): if(!b(c)) called from line 32, column 1210 in eg(a, b): c.setPov(new bg(0,0,1)); called from line 32, column 2787 in lg(a, b): c.l=new eg(a,{visible:l,enableCloseButton:i,Aa:this.Aa}); called from line 23, column 1 in <anonymous function: onload>() in file://localhost/E:/My%20Documents/Others/Andrea/hurtigruten_desktop_reference/hurtigruten.html: var map = new google.maps.Map(canvas); IE6 (Win 2000): Invalid value: [object Object] (Invalid value for property <isArray>: function () { return this.constructor === Array.prototype.constructor; }) This is pretty major as the workaround(s) would be extensive and involved.
Jan 12, 2011
I'm going to repurpose this issue for v3, but in the future could you please file a separate issue because v2 and v3 are completely different. I certainly do not recommend modifying any built-in prototypes, however I'll take a further look into this.
Status:
New
Labels: -ApiType-Javascript ApiType-Javascript3
Feb 27, 2011
Please read the discussion on the v3 group about modifying the object prototype - https://groups.google.com/forum/#!topic/google-maps-js-api-v3/sLnpnZdKklY
Status:
WontFix
Feb 25, 2015
(No comment was entered for this change.)
Status:
Invalid
|
|
| ► Sign in to add a comment |