Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

form.elements not according to w3 spec on safari #217

Closed
janvandenberg opened this issue Feb 27, 2015 · 2 comments
Closed

form.elements not according to w3 spec on safari #217

janvandenberg opened this issue Feb 27, 2015 · 2 comments

Comments

@janvandenberg
Copy link

I have a third-party library which I use that does a IE 6/7 bug detection in my web application:

function testForNamePropertyBug(){
    var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input"));
    input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues
    HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name];
    document.body.removeChild(form);
}

The problem is the line where form.elements[input.name] does not return a nodeList like the spec dictates (https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements) but a simple array. So this test provides a false positive. on Safari 8.0.3 with OSX 10.10.2.

Webcomponents.js is the reason why this happens. It polyfills the elements method and returns the wrong object:

    mixin(HTMLFormElement.prototype, {
      get elements() {
        return wrapHTMLCollection(unwrap(this).elements);
      }
    });

Could it be possible to fix this in future releases of webcomponents.js?

@jmesserly
Copy link
Contributor

Could it be possible to fix this in future releases of webcomponents.js?

unfortunately, it's not possible to polyfill NodeList. (at least until EcmaScript 6 proxies are widely supported.) So there's no action we can take here. A few suggestions:

  • patch your third party library, so it checks for ShadowDOMPolyfill and understands it is not IE6/7 (I doubt webcomponents.js can load on IE < 9 ... see browser support)
  • use webcomponents-lite.js, which omits ShadowDOMPolyfill

@janvandenberg
Copy link
Author

Okay, thanks for the explanation!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants