• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

164
Views
Behaviour of :defined pseudo selector class

I had a script as follows

const custElem = document.createElement('my-elem')
let res = custElem.matches(':defined');
console.log(`custElem.matches(':defined'): ${res}`);

res = custElem.matches(':not(:defined)');
console.log(`custElem.matches(':not(:defined)'): ${res}`);

customElements.define('my-elem', class extends HTMLElement {
    constructor () { 
         super() 
    }
});

res = custElem.matches(':defined');
console.log(`After definition: custElem.matches(':defined'): ${res}`); // EXPECTED TRUE

I expected the last log to yield true. Why does custElem fail to match the :defined selector even after the definition of the custom element?

about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error