I am just looking into extending built-in elements for the first time and have some basic questions.
Let’s say I want to extend a p
element, assign it a class, and make it contenteditable
. Is the following correct and ready-to-use?
customElements.define('p-edit', pedit, { extends: 'p' });
class pedit extends HTMLParagraphElement {
constructor() {
super();
this.classList.add("foo");
this.setAttribute("contenteditable",true);
}
}
And would that pedit
element be a valid jQuery selector
? And would it be a match if the jQuery selector were 'p[contenteditable="true"]'
?