Skip to content
This repository was archived by the owner on Jun 15, 2021. It is now read-only.
This repository was archived by the owner on Jun 15, 2021. It is now read-only.

node.children is undefined? #462

Open

Description

@mindplay-dk

In this function, did you really mean node or element?

Because Node objects do not have the children property - only Element objects have that.

Activity

  1. mindplay-dk commented on Mar 15, 2016

    @mindplay-dk
    Author

    We probably ought to have an extra function to check if a given node is an HTMLElement, and then use that to make an extra assertion before relying on children - something like:

        function isHTMLElement(node) {
            return node instanceof HTMLElement;
        }
    
        function isEmptyInlineElement(node) {
            if (isHTMLElement(node)) {
                if (node.children.length > 1) {
                    return false;
                }
                if (node.children.length === 1 && node.textContent.trim() !== '') {
                    return false;
                }
                if (node.children.length === 0) {
                    return node.textContent.trim() === '';
                }
                return isEmptyInlineElement(node.children[0]);
            }
            return false;
        }
    
  2. self-assigned this
    on Mar 23, 2016
  3. rrees commented on Apr 3, 2016

    @rrees
    Contributor

    I agree with trying to implement the right check

  4. katebee commented on Feb 3, 2017

    @katebee
    Contributor

    @rrees adding labels appears to have unassigned you 😢 (that was not intentional)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions