Bug Tracker

Modify

Ticket #8572 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

jQuery.isPlainObject

Reported by: hidespb Owned by:
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.5.1
Keywords: Cc:
Blocking: Blocked by:

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;}
    
  1. Try to create an element:
    var div = $('<div/>', {
    	class: 'someclass'
    });
    
  1. 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

Change History

comment:1 Changed 2 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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 use className instead.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.