Re: [css-houdini-drafts] What if we could define custom, pseudo-classes? (#1008)

Thoughts on API...

```javascript
async function () {
  /* create a namespace for prefixed selector definitions */
  let ns = await CSS.registerSelectorNamespace('foo') // throws an error if 'foo' namespace has already been committed
  
  /* 
    registers the ":-foo-visible" pseudo-class selector

    callback function determines whether or not the node in question matches the selector
    (similar to Array.prototype.filter)
  */
  ns.registerPseudoClass(':visible', function (node) {
    let meetsCriteria = false
    /* ... */
    return meetsCriteria
  })

  // registers ":-foo-touched"
  ns.registerPseudoClass(':touched', function (node) { /* ... */ })

  // registers ":-foo-changed"
  ns.registerPseudoClass(':changed', function (node) { /* ... */ })

  /* ... */

  /* commit changes to the namespace */
  /* prevents further modification or re-definition of the namespace */
  ns.commit()
}
```

-- 
GitHub Notification of comment by CITguy
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/1008#issuecomment-685215836 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 2 September 2020 00:59:43 UTC