First select.remove(0) might leave the select.options collection one element too short

Issue #11349294 • Assigned to Travis L.

Details

Author
François R.
Created
Mar 21, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
14
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

It seems to me the “options” collection gets updated by the remove of the first element, then is subsequently updated to remove its first item which is not the element to remove. That doesn’t happen all the times, which suggest a flag needs a particular value to repro.

This is a DOM regression probably introduced in RS1.

This issue was reported by an internal team, and manifests it self as Knockout tries to remove all items from a select by calling remove(0) until the list reports length 0, which leaves the second option element of the select in place (it gets removed from the options list incorrectly on the first remove(0)).

More info about this issue can be shared internally, please ping frremy.

Attachments

0 attachments

    Comments and activity

    • Here is a workaround that should fix the issue and therefore unblock Knockout. I doubt any other code would use this api however, it is a very old api from the DHTML days. Looking at Knockout source code they use it to work around an IE8 bug :-)

      void function() {
          var remove = HTMLSelectElement.prototype.remove;
          HTMLSelectElement.prototype.remove = function(index) {
              if(arguments.length == 0) { 
                  this.parentElement.removeChild(this);
              } else {
                  remove.call(this, index);
                  if(this.children[0] != this.options[0]) {
                      this.insertBefore(this.children[0], this.children[1]);
                  }
              }
          }
      }();
      
    • Microsoft Edge Team

      Changed Assigned To to “Steven K.”

      Changed Assigned To to “Travis L.”

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

    Sign in