Side navigation
#8572 closed bug (invalid)
Opened March 20, 2011 09:37PM UTC
Closed March 20, 2011 10:46PM UTC
jQuery.isPlainObject
Reported by: | hidespb | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hi! here's some kinda of bug i've found a few days ago:
1. Change Object's prototype:
Object.prototype.somefunc = foo() {bar;}
2. Try to create an element:
var div = $('<div/>', { class: 'someclass' });
3. Browser throws an Exception:
'TypeError: doc.createElement is not a function'
Reason for this exception is located at line 138:
if ( ret ) { if ( jQuery.isPlainObject( context ) ) { selector = [ document.createElement( ret[1] ) ]; jQuery.fn.attr.call( selector, context, true ); } else { selector = [ doc.createElement( ret[1] ) ]; } }
jQuery.isPlainObject return false on a object having it's prototype modified. In normal case jQuery should use document.createElement, but in case of abnormal return it uses doc.createElement instead.
p.s. sry for bad english
Attachments (0)
Change History (1)
Changed March 20, 2011 10:46PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
1) Don't modify
Object.prototype
because jQuery doesn't support pages that do this.2) Don't use a bareword
class
for a property name because it is a JavaScript reserved word. Either quote the name or useclassName
instead.