Skip to content

insertAdjacentHTML is broken #4

Open

Description

@annevk

It cannot use "insert" directly. That should probably be "pre-insert". And now I introduced "insert adjacent" it should probably reuse that: whatwg/dom@8fa7ac7.

Activity

  1. ArkadiuszMichalski commented on May 4, 2016

    @ArkadiuszMichalski

    "insert adjacent" doesn't fit here because insertAdjacentHTML() for "beforebegin" and "afterend" throw "NoModificationAllowedError" when context doesn't have parent (Firefox/Chrome/IE11 do this but not Presto).
    For insertAdjacentText() and insertAdjacentElement() and the same position whe have:
    Chrome/Firefox return null for insertAdjacentElement()
    IE11 throw for insertAdjacentText() but not for insertAdjacentElement() and return passing element.
    Presto throw for insertAdjacentElement() but not for insertAdjacentText() and return undefined.
    Edge:...
    I will update tests in WPT to check this cases.

  2. annevk commented on May 4, 2016

    @annevk
    MemberAuthor
  3. ArkadiuszMichalski commented on May 4, 2016

    @ArkadiuszMichalski

    Right, probably work, just changing step 4. to use "insert adjacent", parent will be checking earlier.

    @annevk But looks like actual definition is correct, owner for new nodes is setting in fragment parsing algorithm and this method is not flexible like insertBefore(), so never operate on element as context object where parent is Document (because throw), validate from "pre-insert" is unnecessary (other cases, like for Doctype will be catching by XML parser and throw SyntaxError or ignore by HTML parser). Even for "beforeend" P&S can replace "append" by "insert": "Insert fragment into the context object before null" and in all cases we will have "insert". But may be I wrong...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions