Cannot highlight multiple custom elements
Categories
(Core :: DOM: Selection, defect)
Tracking
()
People
(Reporter: jonathonwoolston, Unassigned)
References
(Blocks 2 open bugs)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0
Steps to reproduce:
I was creating a library to simplify the creation of custom components (I wanted to learn how to create a good library and this seemed like a great thing to create a library on, you can find the library on GitHub: https://github.com/Fighter178/libui), and when testing, I noticed that when two of the same custom elements were on the page, you could only highlight one of them.
Actual results:
When highlighting with the mouse, only one element's could be highlighted
Expected results:
When highlighting with the mouse, all of the text on the page should be highlighted when you mouse over all of it.
Reporter | ||
Comment 1•10 months ago
|
||
Should be "element's text" not "element's" in the actual resultss
![]() |
||
Updated•10 months ago
|
Comment 2•10 months ago
|
||
I suspect it is because of shadow DOM.
Hi reporter, would it be possible to share the page that reproduce the issue with us? Thanks.
Reporter | ||
Comment 3•5 months ago
|
||
Sorry for the late reply.
I cannot find the source code for this. I do know that the components did use shadow DOM, and I'm pretty sure that it was closed shadow DOM, but can't be certain.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
class ShadowComponent extends HTMLElement {
constructor(){
super();
const shadow = this.attachShadow({mode:"open"});
const text = document.createElement("p");
text.textContent = "Highlight me (shadow)!";
shadow.append(text);
}
};
class RegularComponent extends HTMLElement {
constructor(){
super();
}
}
customElements.define("my-shadow", ShadowComponent);
customElements.define("my-regular", RegularComponent);
</script>
</head>
<body>
<h2>Shadow DOM:</h2>
<my-shadow></my-shadow>
<my-shadow></my-shadow>
<h2>Regular:</h2>
<my-regular>
<p>Highlight me (regular)!</p>
</my-regular>
<my-regular>
<p>Highlight me (regular)!</p>
</my-regular>
</body>
</html>
You can only highlight one element at a time.
Reporter | ||
Comment 4•5 months ago
|
||
The example that I provided does work too. In Firefox 115.0
![]() |
||
Comment 5•5 months ago
|
||
![]() |
||
Comment 6•5 months ago
|
||
I can reproduce the issue
![]() |
||
Updated•5 months ago
|
Reporter | ||
Comment 7•5 months ago
|
||
Also, can confirm that it also effects mobile.
Reporter | ||
Comment 8•5 months ago
|
||
Tested on mobile Firefox v115.2
Reporter | ||
Comment 9•5 months ago
|
||
Also, you cannot highlight from native elements to shadow dom'ed ones either. Or from shadow dom elements to native
![]() |
||
Updated•5 months ago
|
Comment 10•5 months ago
|
||
Sounds a duplicate of bug 1455893?
Updated•5 months ago
|
Updated•5 months ago
|
Reporter | ||
Comment 11•5 months ago
|
||
Also, this affects ctrl+a
too, and shadow DOM elements cannot be selected with it, even if your cursor is in/clicked into one, it will only select native or non-shadow DOM elements.
Description
•