Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using overloaded native API's for DOMElement #1159

Open
michael opened this issue Feb 13, 2018 · 1 comment
Open

Avoid using overloaded native API's for DOMElement #1159

michael opened this issue Feb 13, 2018 · 1 comment

Comments

@michael
Copy link
Member

michael commented Feb 13, 2018

For instance in some places we use el.nodeType which in our abstraction returns a string:

...
  getNodeType() {
    switch(this.el.nodeType) {
      case window.Node.TEXT_NODE:
        return "text"
      case window.Node.ELEMENT_NODE:
        return 'element'
      case window.Node.DOCUMENT_NODE:
        return 'document'
      case window.Node.COMMENT_NODE:
        return 'comment'
      case window.Node.PROCESSING_INSTRUCTION_NODE:
        return 'directive'
      case window.Node.CDATA_SECTION_NODE:
        return 'cdata'
      default:
        //
    }
  }

We should consider deprecating these problematic native API's and use explicit getters when possible.

E.g. el.isCdataElement() then it is clear this is custom API with different semantics.

@michael
Copy link
Member Author

michael commented Feb 13, 2018

We may also want to use symbols for representing node types. E.g.

const { CDATA } = DOMElement.NodeTypes

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

No branches or pull requests

1 participant