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

Copying a Selection's "inner html" vs "outer html" #168

Closed
danburzo opened this issue Aug 24, 2017 · 2 comments
Closed

Copying a Selection's "inner html" vs "outer html" #168

danburzo opened this issue Aug 24, 2017 · 2 comments

Comments

@danburzo
Copy link

In current browser implementations, doing:

var sel = window.getSelection();
sel.removeAllRanges();
var r = document.createRange();
// this: 
r.selectNode(somenode);
// or this:
r.selectNodeContents(somenode);
sel.addRange(r);

has the same result, whether using selectNode or selectNodeContents, to what is copied to the clipboard:

  • Firefox will put the node's "outer html" to the clipboard's text/html mimetype
  • Chrome and Safari will put the node's "inner html" to the clipboard

See Chrome issue here

I think there needs to be a distinction, allowing developers to decide whether to include the entire node in the clipboard, or just its content.

@rniwa
Copy link
Contributor

rniwa commented Aug 24, 2017

@danburzo
Copy link
Author

Thanks, @rniwa! I've logged a bug on the Clipboard APIs repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants