Skip to content
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 list filter on paste for RN mobile. #17550

Merged
merged 9 commits into from
Sep 26, 2019
4 changes: 3 additions & 1 deletion packages/blocks/src/api/raw-handling/list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ function isList( node ) {
}

function shallowTextContent( element ) {
return [ ...element.childNodes ]
// On mobile DOM implmentation NodeList is not spreadable so we need to convert it to an array.
SergioEstevao marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment doesn't make entirely sense to me. The web implementation also needs to be converted to a real array, but it happens to be spreadable. In general we should always use Array.from. I believe we do in most places. Is this the only instance where we spread to convert it to a real array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the comment. I don't know if this is the only instance were we spread the NodeList, I just tracked down the bug I was seeing when doing paste without format on the RN app and got to this method.

const nodesArray = Array.prototype.slice.call( element.childNodes );
return nodesArray
.map( ( { nodeValue = '' } ) => nodeValue )
.join( '' );
}
Expand Down