cloneNode called on an image element does not clone before element was added to dom (if using relative url)

Issue #13696469 • Assigned to travil

Details

Author
Simon S.
Created
Sep 12, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
  • Internet Explorer
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

While working on code for the openlayers library (https://github.com/openlayers/openlayers) I found this issue. The following code reproduces the issue:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <canvas id="cnvs" width="100" height="100"></canvas>
    <script>
      var img = document.createElement('img');
      img.src = 'images/icon.png'; // it has to be a relative url
      
      var canvas = document.getElementById('cnvs');
      var context = canvas.getContext('2d');
      
      img.addEventListener('load', () => {
        var clone = img.cloneNode(true);
        //document.body.appendChild(clone); // if this line is uncommented it works
        context.drawImage(clone, 0, 0);
      });
    </script>
  </body>
</html>

This -might- be related to https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/104032/

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “James M.”

      Changed Assigned To to “travil”

    You need to sign in to your Microsoft account to add a comment.

    Sign in