Bug 11561

Summary: Element is incorrectly rendered when is created, removed and created again using DOM methods
Product: WebKit Reporter: Miroslav Juhos <mjuhos>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: mitz, pdousa
Priority: P2    
Version: 420+   
Hardware: Mac (Intel)   
OS: OS X 10.5   
Attachments:
Description Flags
Testcase
none
Screenshot - incorrectly rendered DIV element none

Description Miroslav Juhos 2006-11-10 03:41:33 PST
Overview Description: 
Element is incorrectly rendered when is created, removed and created again using DOM methods

Steps to Reproduce: 
1) Open testcase
2) Click into document by right mouse button
3) Move mouse about 50 px right and press right mouse button again

Actual Results: 
DIV element isn't correctly rendered (text in element isn't visible).

Expected Results: 
DIV element will be correctly rendered.

Build Date & Platform: 
    Build 2006-11-10 on Mac OS 10.5.

Test case:
<html>
  <head>
    <style>
      #menu {
        background-color:blue;
        position:absolute;
        width:200px;
      }
    </style>
    <script>
      var k_e;

      function dsp() {
        var k_contextMenu = document.getElementById("menu");
        if (!k_contextMenu) {
          k_contextMenu = document.createElement('div');
          k_contextMenu.id = 'menu';
          for (var i =1; i < 10; i++) {
            k_contextMenu.innerHTML += '<div>item ' + i + '</div>';
          }
          document.body.appendChild(k_contextMenu);
        }
        k_contextMenu.style.left = k_e.clientX + 'px'
        k_contextMenu.style.top = k_e.clientY + 'px';
      }
      function removeMenu() {
        var k_contextMenu = document.getElementById("menu");
        if (k_contextMenu) {
          var k_p = k_contextMenu.parentNode;
          k_p.removeChild(k_contextMenu);
        }
      }

      function showMenu() {
        removeMenu();
        k_e = event;
        dsp();
      }
    </script>
  </head>
  <body oncontextmenu="showMenu();return false;" onmousedown="removeMenu()">
  </body>
</html>

Workaround:
Replace calling of function dsp() by setTimeout('dsp();',0)
Comment 1 Miroslav Juhos 2006-11-10 03:43:05 PST
Created attachment 11457 [details]
Testcase
Comment 2 Miroslav Juhos 2006-11-10 03:44:11 PST
Created attachment 11458 [details]
Screenshot - incorrectly rendered DIV element
Comment 3 mitz 2006-11-10 04:38:49 PST
I am unable  to reproduce with locally built r17702 on Tiger.
Comment 4 Alexey Proskuryakov 2006-11-11 03:18:46 PST
Please file any issues you find when using Leopard via <http://bugreport.apple.com>.
Comment 5 Miroslav Juhos 2006-11-13 02:18:47 PST
Reported as Bug ID# 4833454 via http://bugreport.apple.com.