WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#31988 closed defect (bug) (fixed)

TinyMCE: pasting an embeddable URL in Firefox doesn't show preview

Reported by: azaozz Owned by: azaozz
Milestone: 4.2 Priority: high
Severity: normal Version: 4.2
Component: TinyMCE Keywords: has-patch commit
Focuses: Cc:
PR Number:

Description

Caused by our regex test whether the selected parahraph has any text content.

When there is no text content (most common case), typeof( node.textContent || node.innerText ) is "undefined" in Firefox but "string" in Chrome. The regex test fails for undefined and passes for string.

Attachments (2)

31988.patch (729 bytes) - added by azaozz 5 years ago.
31988.2.patch (700 bytes) - added by iseulde 5 years ago.

Download all attachments as: .zip

Change History (11)

@azaozz
5 years ago

#1 @azaozz
5 years ago

  • Priority changed from normal to high

In 31988.patch: if the node doesn't have textContent or innerText (for old IE), pass empty string to the regex.

This ticket was mentioned in Slack in #core-editor by azaozz. View the logs.


5 years ago

#3 @DrewAPicture
5 years ago

  • Keywords has-patch added

31988.patch fixes it for me. Nice find, this has been a longstanding problem for me.

@iseulde
5 years ago

#4 @iseulde
5 years ago

It fails because Firefox does not support node.innerText. That runs because node.textContent may evaluate false if it's an empty string and so null is returned. Patch fixes the problem, but maybe better to use the TinyMCE API for these things?

#5 @DrewAPicture
5 years ago

  • Owner set to azaozz
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core by drew. View the logs.


5 years ago

#7 @DrewAPicture
5 years ago

  • Keywords commit added

Tested 31988.2.patch, and it also works for me. Moving for commit consideration.

#8 @azaozz
5 years ago

Yeah, we can use either patch, they are equivalent. I'd still do

/^[\s\uFEFF\u00A0]*$/.test( $( node ).text() || '' )

just in case as it is passed directly to a regex method that expects string.

#9 @azaozz
5 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 32229:

TinyMCE: fix creating a preview when pasting an embeddable URL in Firefox.
Part prop iseulde. Fixes #31988.

Note: See TracTickets for help on using tickets.