question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EditMode not working properly in ShadowDOM

See original GitHub issue

Hi @susielu , Thank you for this great d3 plugin. Really love working with it. I encountered a problem when using d3-annotation inside a shadowDOM:

Problem:

My svg element lives inside a shadowDOM. If the element is in editMode it is not possible to drag the annotation handles. I have created a codepen to reproduce the problem -> https://codepen.io/anon/pen/GzqvbY?editors=1010

Try to drag the annotation handles and check the console for the error message (Cannot read property ‘ownerSVGElement’ of null).

Possible solution

I did some debugging and found out that the drag handler is registered on all elements passing this selector g.annotations (see code here):

drag().container(select("g.annotations").node())

This doesn’t play nicely with shadowDOM, because the svg element inside the shadowDOM is not visible from outside. A possible solution could be to make the selection relative to the annotation-group:

drag().container(group.selectAll("g.annotations").node())

I wanted to create a PR but failed to implement a working solution. Do you have an idea how we could fix this?

Kind regards, Manuel

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
manuelrothcommented, Mar 24, 2019

Hi @susielu, just wanted to let you know that I used your library to cover communal elections in the canton of zurich (switzerland). Thank you so much, it let us build this in a very short time -> https://www.nzz.ch/zuerich/regierungsrat-und-kantonsrat-zuerich-die-resultate-der-wahlen-ld.1465859?h

Bildschirmfoto 2019-03-24 um 14 55 47

Kind regards, Manuel

1reaction
susielucommented, Feb 5, 2019

Hey Manuel, thanks for posting this. I haven’t worked with the shadowDOM before. Thanks for making a codepen example. I’ll take a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styling shadow-dom elements in audio element on webkit ...
Problem 1: Styling the first letter in the remaining-display div does not work. The following rule is not effective. audio::-webkit-media- ...
Read more >
Does not work in Shadow DOM in Safari 10. #476 - GitHub
When ProseMirror adopts an element inside a Shadow DOM in Safari 10, an exception is thrown. The reason appears to be that in...
Read more >
Testing in the shadow DOM - mabl Documentation
Shadow DOM makes it possible to embed components, such as buttons or forms, into a page and keep them isolated from other components...
Read more >
348991 - DevTools cannot edit content in shadow DOM
Steps to reproduce the problem: 1. Visit http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom-301. ... 3. Right-click the text two lines ...
Read more >
Using shadow DOM - Web Components | MDN
SVG version of the diagram showing the interaction of document, shadow root and shadow host. There are some bits of shadow DOM terminology...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found