Bug 9504 - img tag rewritten by innerHTML doesn't use image map
Summary: img tag rewritten by innerHTML doesn't use image map
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: Mac All
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
: 19678 26277 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-19 03:39 PDT by Martin Hinks
Modified: 2010-07-13 10:09 PDT (History)
10 users (show)

See Also:


Attachments
proposed fix (6.09 KB, patch)
2010-06-09 17:23 PDT, Alexey Proskuryakov
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Hinks 2006-06-19 03:39:06 PDT
Test case #1: http://www.m-s-d.net/test.htm
Test case #2: http://www.m-s-d.net/test2.htm

Test case #1 shows a <span> tag being rewritten to contain an img tag with a usemap property and a <map> tag complete with areas. The write works when called from anything other than the function called when the imagemap is clicked. ie. it works on page load, but rewriting the tag via a function called from a click on the imagemap does not. After the rewrite called from within the imagemap click the zonemap does not work.

Test case #2 shows a <span> tag being rewritten to contain an img tag with a usemap property. The map is stored inline with the document after the span tag and not generated dynamically. In this case the zonemap never functions correctly.

These behaviours work as expected in Firefox and Internet Explorer (tested on WinXP SP2)
Comment 1 Martin Hinks 2006-06-19 03:52:56 PDT
My mistake: test case #2 now shows a working example thereby showing that it is the rewrite of the map that causes the failure.

(In reply to comment #0)
> Test case #1: http://www.m-s-d.net/test.htm
> Test case #2: http://www.m-s-d.net/test2.htm
> 
> Test case #1 shows a <span> tag being rewritten to contain an img tag with a
> usemap property and a <map> tag complete with areas. The write works when
> called from anything other than the function called when the imagemap is
> clicked. ie. it works on page load, but rewriting the tag via a function called
> from a click on the imagemap does not. After the rewrite called from within the
> imagemap click the zonemap does not work.
> 
> Test case #2 shows a <span> tag being rewritten to contain an img tag with a
> usemap property. The map is stored inline with the document after the span tag
> and not generated dynamically. In this case the zonemap never functions
> correctly.
> 
> These behaviours work as expected in Firefox and Internet Explorer (tested on
> WinXP SP2)
> 

Comment 2 Alexey Proskuryakov 2007-03-31 12:23:18 PDT
These test cases are now longer available. Reporter, could you please attach them to the bug?
Comment 3 Martin Hinks 2007-04-01 09:32:20 PDT
> Test case #1: http://www.m-s-d.net/test.htm
> Test case #2: http://www.m-s-d.net/test2.htm
> 

Now at:

Test case #1: http://www.2bitpie.net/test.htm
Test case #2: http://www.2bitpie.net/test2.htm
Comment 4 Alexey Proskuryakov 2008-11-28 13:38:44 PST
These test cases are now longer available. Reporter, could you please attach
them to the bug?
Comment 5 Alexey Proskuryakov 2009-06-15 12:21:19 PDT
*** Bug 26277 has been marked as a duplicate of this bug. ***
Comment 6 Alexey Proskuryakov 2009-06-15 12:22:21 PDT
Bug 26277 has a test attached.
Comment 7 Don Marks 2009-11-04 05:49:41 PST
This problem can be worked around by renaming the old map to something inconsequential before it is replaced. 
For example: 
map.name = 'garbage';
mapparent.innerHTML = '<map name="mymap" ...';
Comment 8 Don Marks 2009-11-04 08:38:54 PST
I should add that even though this workaround seems to do the job, there is likely still a small memory leak of a reference to the now-deleted map being kept around.

If the map is renamed each time to a unique name, then an even bigger memory leak would likely occur.
Comment 9 Alexey Proskuryakov 2010-06-08 14:52:54 PDT
See also: bug 19678.
Comment 10 Alexey Proskuryakov 2010-06-09 16:46:27 PDT
*** Bug 19678 has been marked as a duplicate of this bug. ***
Comment 11 Alexey Proskuryakov 2010-06-09 17:23:06 PDT
Created attachment 58314 [details]
proposed fix

I think that the workaround from comment 7 is a good one, there shouldn't be any memory leak.
Comment 12 Alexey Proskuryakov 2010-06-09 22:33:45 PDT
Committed <http://trac.webkit.org/changeset/60937>.
Comment 13 WebKit Review Bot 2010-06-09 23:01:52 PDT
http://trac.webkit.org/changeset/60937 might have broken SnowLeopard Intel Release (Tests)
Comment 14 Alexey Proskuryakov 2010-07-13 10:09:57 PDT
Actually landed the test at last, <http://trac.webkit.org/changeset/63217>.