Node#isEmpty considers nbsp-only node as non-empty
@Afraithe is already working on this.
Since Aug 8, 2018.
- Dominant language
- TypeScript
- Stars
- 16.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Do you want to request a feature or report a bug?
Bug. (Or verification of intent).
What is the current behavior?
When a new block is created, it is padded with an non-breaking space character. The behavior of Node#isEmpty disregards whitespace, but not specifically the non-breaking space character.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via fiddle.tinymce.com or similar.
Demo: http://fiddle.tinymce.com/Pugaab
Enter some content and press Enter.
More directly, it could be reproduced by a test case on creating an empty text node.
const documentNode = Node.create( '#document-fragment' );
const textNode = Node.create( '#text' );
textNode.value = String.fromCharCode( 160 );
documentNode.append( textNode );
console.log( documentNode.isEmpty() );
// false
Possible solution: If changing the regular expression to use \s instead of , isEmpty correctly returns true.
Before:
After:
const whiteSpaceRegExp = /^[\s\t\r\n]*$/;
What is the expected behavior?
The logged result should show "Is empty: true" since it is for the newly-created empty paragraph.
Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE?
TinyMCE 4.7.13
Unaware of previous working state.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.