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

Implement jsdom node traversal properties #1083

Merged
merged 1 commit into from
Jun 10, 2019

Conversation

mkevins
Copy link
Contributor

@mkevins mkevins commented Jun 6, 2019

Fixes #827

Description

This PR aims to fix an issue on mobile (#827) where pasted content from certain sources omits the images. Related comment: #617 (review), and a clipboard snippet of html that reproduces the issue on mobile here: #827 (comment).

Steps to test:

  1. Select content from this site, including text above and below the image above "The Visual Editor.". Alternatively, if you are using an emulator with shared clipboard, it suffices to copy the html from the snippet referenced above.
  2. Create an empty paragraph block.
  3. Paste the contents.

Types of changes

When some content is pasted, a code path in figure-content-reducer.js expects parentElement property to be implemented when finding the containing <p> element (ancestor) surrounding an image element. Because parentElement is not implemented in the DOM for the mobile environment, <img> elements contained within <p> elements are not properly unwrapped, and are thus removed in a subsequent call to cleanNodeList.

It was noted in an earlier PR that we may encounter similar issues in other code paths as a result of our limited DOM implementation. These changes implement the parentElement property on the Node.prototype, as well as the previousElementSibling and nextElementSibling properties on the Node.prototype for all node implementing the NonDocumentTypeChildNode pure interface.

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@mkevins mkevins added this to the v1.7 milestone Jun 6, 2019
@mkevins mkevins requested a review from hypest June 6, 2019 07:33
Copy link
Contributor

@hypest hypest left a comment

Choose a reason for hiding this comment

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

LGTM and pasting according to the test steps works nicely!

@hypest hypest merged commit 409e70b into develop Jun 10, 2019
@hypest hypest deleted the try/implement-dom-node-traversal-properties branch June 10, 2019 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pasting images along with text sometimes omits the images
2 participants