class Test extends HTMLElement{
constructor(){
super()
let shadow = this.attachShadow({mode:'open'});
let text = this.getAttribute('text')
if(text==null || text=="")
text = 'null'
let e = document.createElement("h3")
e.textContent = text
shadow.appendChild(e);
}
}
window.customElements.define('my-test', Test);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="./main.js"></script> # script line
<my-test text="hello webcomponent"/> # element line
</body>
</html>
Please tell my where i am wrong. Thank you.