Skip to content

template compilation wrong identification of whitespaces let transition-group fail with exception "Cannot read properties of null (reading 'getBoundingClientRect')" #5153

Closed
@terenzif

Description

@terenzif

Version

3.2.26

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Create a transition-group with nested elements
Condense template removing \r \n keeping only spaces between tags

What is expected?

This should work without warnings

What is actually happening?

It gets the error:
Cannot read properties of null (reading 'getBoundingClientRect')


The cause of the reported error come from this section of parseChildren function:

                      if (!prev ||
                          !next ||
                          (shouldCondense &&
                              (prev.type === 3 /* COMMENT */ ||
                                  next.type === 3 /* COMMENT */ ||
                                  (prev.type === 1 /* ELEMENT */ &&
                                      next.type === 1 /* ELEMENT */ &&
                                      /[\r\n]/.test(node.content))))) {
                          removedWhitespace = true;
                          nodes[i] = null;
                      }
                      else {
                          // Otherwise, the whitespace is condensed into a single space
                          node.content = ' ';
                      }

The problem is, if section has only spaces without \r or \n, it doesn't get removed but replaced with a space.
This make render a text section inside a transition-group between animated elements, which cannot be animated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions