Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#6779 closed bug (fixed)

Dom Manipulation fails if added text happens to match Object method

Reported by: cscott Owned by: dmethvin
Priority: high Milestone:
Component: manipulation Version: 1.4.4
Keywords: dommanip cache Cc:
Blocked by: #5876 Blocking:

Description

When you try to add the text "hasOwnProperty", for example, the dom manipulation cache "finds" hasOwnProperty and tries to add a *function* to the DOM. This also holds for any other methods of Object.

The attached patch fixes the problem, by using hasOwnProperty to ensure that the cache match isn't actually an Object method. (We also need to ensure that hasOwnProperty isn't cacheable.)

Attachments (1)

0001-Avoid-problems-when-adding-text-which-happens-to-mat.patch (1.4 KB) - added by cscott 13 years ago.
Patch to fix the problem.

Download all attachments as: .zip

Change History (11)

Changed 13 years ago by cscott

Patch to fix the problem.

comment:2 Changed 12 years ago by Rick Waldron

Owner: set to cscott
Priority: undecided
Status: newpending

Please provide a reduced jsFiddle test case, thanks!

comment:4 Changed 12 years ago by dmethvin

snover suggested we just not cache strings that have no html, that would fix the problem with a simple test for '<'.

comment:5 Changed 12 years ago by snover

Blocked by: 5876 added
Milestone: 1.4.3
Priority: undecidedhigh
Status: pendingopen
Version: 1.4.21.4.4

Beyond just not testing for strings with no HTML, I suggested to only cache strings where the first character is a <.

comment:6 Changed 12 years ago by snover

Keywords: dommanip cache added

comment:7 Changed 12 years ago by dmethvin

Owner: changed from cscott to dmethvin
Status: openassigned

comment:9 Changed 12 years ago by Dave Methvin

Resolution: fixed
Status: assignedclosed

Don't cache non-html strings in buildFragment to avoid possible collision with the names of Object methods like toString. Also makes the unit tests 0.5% to 8% faster. Fixes #6779.

Changeset: 5fd21fc02bda43d4e31bcf2d5b55b918a9190a7f

comment:10 Changed 12 years ago by Dave Methvin

Don't cache non-html strings in buildFragment to avoid possible collision with the names of Object methods like toString. Also makes the unit tests 0.5% to 8% faster. Fixes #6779.

Changeset: 5fd21fc02bda43d4e31bcf2d5b55b918a9190a7f

Note: See TracTickets for help on using tickets.