10

I'm using AngularJS 1.5.0 and Microsoft Edge browser screen doesn't reflect the DOM.

I would like some suggestion how this can be fixed.

I can't really apply a fix for each element as the application is somewhat big with dynamic user content including Angular equations. Also the app include a lot of dynamic bindings linked to input boxes.

Selecting the text with the mouse turn the 0 into a 2 which is the right value in the example below. Also changing the position style back and forth seem to force Edge to redraw the element but it's somewhat an ugly fix that I don't like very much and it need to be trigger at so many places (Ajax request, input changes and so on...)

The page start with a value of 0. Then an Ajax call is made and it go fetch the real data. After some experimentation the bug only appears if the new data is 1 character (ex: 2 or 9). And it happens every time. If it's a 2 digit number (ex: 26) then the good number appears.

Any help on this matter would be gladly appreciated.

enter image description here

6
  • 1
    I've heard reports of issues like this; is this page online for direct access? I work on the Microsoft Edge team, and would love to take a closer look. One thing you can try, is force a repaint of the element after the value has changed. There are numerous ways to do this—you could try, for instance, setting the background: auto on the element.
    – Sampson
    Commented Feb 16, 2016 at 23:05
  • @Sampson. I contacted you via a private message in twitter to give you the url, username and password Commented Feb 17, 2016 at 20:20
  • @Sampson any updates on this? Some parts of our application appear broken because of this bug and one of our clients is planning to update to Microsoft Edge soon...
    – Wilgert
    Commented Apr 7, 2016 at 13:34
  • @Sampson i made small page, where you can reproduce bug. test.veikus.com Commented May 19, 2016 at 13:46
  • was any solution to this found?
    – Cam
    Commented Aug 3, 2016 at 19:56

2 Answers 2

7

We were facing the same problem and it stopped occurring after removing the text-transform: uppercase style from the elements that are not updating.

@Sampson, it looks like this is a bug in Edge.

6
  • 2
    I am thinking the issue here may be with the first state and second state having the same dimensions, and thus the browser doesn't think it needs to update. For instance, try multiplying the latter state by 10 (resulting in a number with more digits). I'm curious if this too resolves the issue.
    – Sampson
    Commented Apr 7, 2016 at 18:02
  • @Sampson yes it actually does. We are also binding to numbers and when the number of digits changes it does update.
    – Wilgert
    Commented Apr 8, 2016 at 7:27
  • 1
    I had it too. In my case, switching off text-transform: uppercase also fixed the issue. Commented May 18, 2016 at 20:20
  • 3
    EDGE should die slowly and painfully!
    – Yulian
    Commented Jul 1, 2016 at 11:26
  • 1
    According to the EDGE issue tracker this is now fixed: developer.microsoft.com/en-us/microsoft-edge/platform/issues/… - It is unclear if it is fixed in the public version or only in internal versions.
    – Wilgert
    Commented Jul 15, 2016 at 8:53
0

I was able to make a temporary fix with the use of Mutation Observer.

Little script that I made that works for AngularJS elements created server side.

Currently those are the only one causing trouble in my app.

<script>    
$(document).ready(function(){
  var ua = navigator.userAgent;
  var re  = new RegExp("Edge/");
  if (re.exec(ua) != null){
    console.log('edgeMutationObserver ON!!')
    var edgeMutationConfig = { characterData: true, subtree: true };
    var edgeMutationObserver = new MutationObserver(function(mutations) {
      var rgb_p = /rgb\((\d+), (\d+), (\d+)\)/g;
      var rgba_p = /rgba\((\d+), (\d+), (\d+), (\d.?\d*)\)/g;

      mutations.forEach(function(mutation){
        if(mutation.target.nodeType == 3){
          var that = mutation.target.parentNode;
          // Save the background color
          var bgc = that.style.backgroundColor;

          // Get applied style from style or css
          var bgc_css = bgc || $(that).css('backgroundColor');
          var bgc_temp,match;
          if(match = rgb_p.exec(bgc_css)){
            // rgb transformed in rgba triggers update
            bgc_temp = 'rgba('+match[1]+','+match[2]+','+match[3]+',1)';
          }else if(match = rgba_p.exec(bgc_css)){
            // Slightly modify transparency
            var alpha = match[4] == 0 ? 0.01 : match[4] - 0.01 ;
            bgc_temp = 'rgba('+match[1]+','+match[2]+','+match[3]+','+alpha+')'; 
          }else{
            // If either inline style or css is already equal to transparent the redraw is not made so i choose an alternate color with 0 opacity
            bgc_temp = bgc_css != 'transparent' ? 'transparent' : 'rgba(0,0,0,0)'; 
          }

          // Change background color to force redraw
          that.style.backgroundColor = bgc_temp;
          setTimeout(function(){
            // Apply back previous style
            // Doesn't redraw without a timeout in Edge
            that.style.backgroundColor = bgc;
          },0);
        }
      });
    });

    $('.ng-binding').each(function(){
      edgeMutationObserver.observe(this, edgeMutationConfig);
    });
  }
});
</script>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.