Edit in JSFiddle

<x-test></x-test>

              
class test extends HTMLElement {
	constructor() {
  	super()
    this.shadow = this.attachShadow({ mode: 'open' })
    this.shadow.innerHTML = '<p>нажми</p>'
  }
}

customElements.define("x-test", test)

document
	.querySelector('x-test')
  .shadowRoot
  .querySelector('p')
  .addEventListener('click', () => alert('нажал'))