Bug 50027 - Appending text with jQuery append() sometimes has no visible effect
Summary: Appending text with jQuery append() sometimes has no visible effect
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://stackoverflow.com/questions/42...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-24 08:52 PST by Alex Ford
Modified: 2010-11-25 22:05 PST (History)
1 user (show)

See Also:


Attachments
test case (2.23 KB, text/html)
2010-11-25 16:27 PST, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Ford 2010-11-24 08:52:50 PST
If you go here: http://stackoverflow.com/questions/4265710/i-need-a-workaround-for-a-safari-chrome-bug-that-is-becoming-a-thorn-in-my-side

I tried to provide as much detail as possible. This bug seems to crop up in every version I've tried so far. It is a minor bug and there is a work around but I just thought you should be aware of it. The workaround is in the selected answer, but don't be confused....the solution was not to use $(element).html($(element).html() + char); instead of $(element).append(char); Both of those methods suffer the same effects of the bug. The solution was to use JQuery's .text() function. $(element).text($(element).text() + char);

I am sure that if JQuery had a HTML encoded version of .append() that would have worked also, but it does not have that.
Comment 1 Alexey Proskuryakov 2010-11-25 16:25:50 PST
In the future, please post all relevant information in Bugzilla. Making everyone click through a link to an external site just wastes time.

I can reproduce this bug in Safari 5.0.3 on Mac and with nightlies. Steps to reproduce:
1) Open http://www.jsfiddle.net/Chevex/6n5VV/
2) Observe text being automatically typed.

Typing often stops midway. Resizing the browser window makes the rest of the text appear.
Comment 2 Alexey Proskuryakov 2010-11-25 16:27:46 PST
Created attachment 74896 [details]
test case

Attaching the same test case, modified to reference uncompressed jQuery.

As a side note, it's quite inefficient to add text with append() - it adds a separate text node for every character, meaning there will be lots.
Comment 3 Alex Ford 2010-11-25 20:16:28 PST
Your note about .append() being inefficient is irrelevant as this bug happens even if you use .html(.html() + newHtml);

Also, noted about using external links to discuss a bug. I just already put so much info over there that I felt it redundant to include it twice when I could just link.