Add attribute-equal selector
Wed Feb 10 08:50:16 UTC 2010 pix@kepibu.org
* Add attribute-equal selector
hunk ./notes 158
-*** attribute selectors [1/7]
+*** attribute selectors [2/7]
hunk ./notes 160
- * [ ] attribute-equal [att=val]
+ * [X] attribute-equal [att=val]
hunk ./selectors.lisp 45
-(defclass attribute-selector (simple-selector) ())
+(defclass attribute-selector (simple-selector)
+ ((val :reader attribute-value :initarg :value)))
hunk ./selectors.lisp 48
+(defclass attribute-equal-selector (attribute-selector) ())
hunk ./selectors.lisp 115
+ (#T(regexp$ ("[" $name "=" $name "]") (?attribute ?value))
+ (cons (make-instance 'attribute-equal-selector :arg attribute :value value)
+ (parse-selector &rest)))
hunk ./selectors.lisp 279
+(defmethod subject-p ((selector attribute-equal-selector) element)
+ (when-let* ((val (element-attribute (selector-arg selector) element)))
+ (string= val (attribute-value selector))))
+
hunk ./tests.lisp 160
+(serialize-values
+ (match (#T(html (:model dom)
+ ("[id=foo]" . ?id))
+ "<div><i id='bar'>bar id</i><i>no id</i><i id='foo'>foo id</i></div>")
+ id))
+