Skip to main content

Bug Tracker

Side navigation

#13671 closed bug (duplicate)

Opened March 26, 2013 11:35PM UTC

Closed March 27, 2013 01:33AM UTC

Extending Object.prototype breaks jQuery 1.8.0+ in IE8 quirks mode

Reported by: anonymous Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

Extending Object.prototype breaks at least getting elements by ID where the ID contains colons requiring escaping.

Affected browser: IE8 in quirks mode

Affected jQuery versions: 1.8.0+

<html>
  <head><title>Title</title></head>
  <body>
    <div id="id:with:colons">This is some text.</div>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
      Object.prototype.someFunctionName = function() { };
      alert($('#id\\\\:with\\\\:colons').text());
    </script>
  </body>
</html>
Attachments (0)
Change History (4)

Changed March 26, 2013 11:43PM UTC by m_gol comment:1

_comment0: You are doing two '''very''' wrong and very unsupported things - primo: extending Object.prototype is a '''really''' bad idea, lots of things can break because of that; secundo: you shouldn't write anything in quirks mode (it's 2013, come on!) and jQuery doesn't support it (and never has).1364342115993165
resolution: → notabug
status: newclosed

There are two problems with your code - primo: extending Object.prototype is a really bad idea, lots of things can break because of that; secundo: you shouldn't write anything in quirks mode (it's 2013, come on!) and jQuery doesn't support it (and never has).

Changed March 26, 2013 11:59PM UTC by anonymous comment:2

I don't own the code doing this but have to extend it but I was not aware that jQuery does not support quirks mode.

If somebody else runs into this problem - it works at least with jQuery 1.6 (didn't test below) and up to 1.7.2. I work around the problem by temporarily removing and later restoring the function added to Object.prototype.

Changed March 27, 2013 01:32AM UTC by rwaldron comment:3

resolution: notabug
status: closedreopened

Changed March 27, 2013 01:33AM UTC by rwaldron comment:4

resolution: → duplicate
status: reopenedclosed

Duplicate of #2721.http://contribute.jquery.org/wont-fix/