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

Fix raw transforms not working in Edge when pasting content #10077

Merged
merged 1 commit into from Sep 30, 2018

Conversation

Projects
None yet
2 participants
@talldan
Contributor

talldan commented Sep 20, 2018

Description

I noticed raw transforms weren't being triggered in MS Edge when pasting markup.

Diagnosis
This error is being thrown

Invalid attempt to spread non-iterable instance

that's being thrown on line 234 here:

const { items = [], files = [] } = clipboardData;
const item = find( [ ...items, ...files ], ( { type } ) => /^image\/(?:jpe?g|png|gif)$/.test( type ) );

items is a DataTransferItemList and files is null. Because files is null a default value of [] is not being set (in the destructuring on line 233).

Fix
I've added a check for both null and undefined using lodash isNil.

How has this been tested?

In Edge:

  • Paste some markup that will trigger a raw transform:
<table>
	<tbody>
		<tr>
			<td>1</td>
			<td>2</td>
		</tr>
		<tr>
			<td>3</td>
			<td>4</td>
		</tr>
	</tbody>
</table>
  • Observe that a table block is created and no errors are thrown.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@talldan talldan self-assigned this Sep 20, 2018

@talldan talldan added this to the 4.0 milestone Sep 20, 2018

@talldan talldan changed the title from Handle files being null in Edge browser when pasting text content to Fix raw transforms not working in Edge when pasting content Sep 20, 2018

@talldan

This comment has been minimized.

Show comment
Hide comment
@talldan
Contributor

talldan commented Sep 21, 2018

@talldan talldan referenced this pull request Sep 21, 2018

Closed

Add inlineStyle matcher for sourcing block attributes #10074

4 of 4 tasks complete

@talldan talldan requested review from tofumatt and noisysocks and removed request for tofumatt Sep 24, 2018

@mcsf

mcsf approved these changes Sep 30, 2018

@talldan talldan merged commit 07b55fb into master Sep 30, 2018

2 checks passed

codecov/project 48.64% (-0.01%) compared to e5d77bd
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@talldan talldan deleted the fix/edge-paste-issue branch Sep 30, 2018

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