chjj / zest

An absurdly fast CSS selector engine.
MIT License
238 stars 14 forks source link

:read-only and :read-write #8

Closed arextar closed 12 years ago

arextar commented 12 years ago

An element whose contents are not user-alterable is :read-only.

I think read-only should look at the contenteditable attribute and whether or not the element is an input element. Also: a disabled text input could be considered read-only.

arextar commented 12 years ago
 ':read-only': function(el) {
    var nodeName = el.nodeName;
    return (nodeName !== "INPUT" && nodeName !== "TEXTAREA" || el.disabled) && el.getAttribute("contenteditable") === null;
  }

A quick test of the function: http://jsfiddle.net/nG6bu/1/embedded/result/

arextar commented 12 years ago

I can open a pull request if you think this is a good idea

chjj commented 12 years ago

Looks good to me.