#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)
Change History (11)
Changed 13 years ago by
Attachment: | 0001-Avoid-problems-when-adding-text-which-happens-to-mat.patch added |
---|
comment:1 Changed 13 years ago by
Patch also in github as: http://github.com/cscott/jquery/commit/7dbc01ae248b1abd8751fdff1ec0891b6ba1d5c6
comment:2 Changed 12 years ago by
Owner: | set to cscott |
---|---|
Priority: | → undecided |
Status: | new → pending |
Please provide a reduced jsFiddle test case, thanks!
comment:4 Changed 12 years ago by
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
Blocked by: | 5876 added |
---|---|
Milestone: | 1.4.3 |
Priority: | undecided → high |
Status: | pending → open |
Version: | 1.4.2 → 1.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
Keywords: | dommanip cache added |
---|
comment:7 Changed 12 years ago by
Owner: | changed from cscott to dmethvin |
---|---|
Status: | open → assigned |
comment:9 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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
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
Patch to fix the problem.