Opened 11 years ago
Closed 11 years ago
#8572 closed bug (invalid)
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:
- Change Object's prototype:
Object.prototype.somefunc = foo() {bar;}
- Try to create an element:
var div = $('<div/>', { class: 'someclass' });
- 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
Note: See
TracTickets for help on using
tickets.
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.