Fri Nov 13 07:56:08 UTC 2009 pix@kepibu.org
* Whoops. Those should still be id
diff -rN -u old-Oh, Ducks!/tests.lisp new-Oh, Ducks!/tests.lisp
--- old-Oh, Ducks!/tests.lisp 2015-04-10 16:12:29.000000000 +0000
+++ new-Oh, Ducks!/tests.lisp 2015-04-10 16:12:30.000000000 +0000
@@ -1,8 +1,8 @@
(in-package #:css-selector-unifier)
-(equalp '(:div ((:element-id "element-id")) "I " (:i () "like") " cheese.")
- (match (#T(lhtml ("#element-id" . ?div))
- "<div element-id=\"element-id\">I <i>like</i> cheese.</div>")
+(equalp '(:div ((:id "id")) "I " (:i () "like") " cheese.")
+ (match (#T(lhtml ("#id" . ?div))
+ "<div id=\"id\">I <i>like</i> cheese.</div>")
;; FIXME: learn to distinguish between when there should only be one
;; result and when there should be many?
(car div)))
diff -rN -u old-Oh, Ducks!/unification-templates.lisp new-Oh, Ducks!/unification-templates.lisp
--- old-Oh, Ducks!/unification-templates.lisp 2015-04-10 16:12:29.000000000 +0000
+++ new-Oh, Ducks!/unification-templates.lisp 2015-04-10 16:12:30.000000000 +0000
@@ -16,13 +16,13 @@
(defmethod make-template ((kind (eql 'lhtml)) (spec cons))
(format t "spec: ~s~%" spec)
- (make-instance 'lhtml-template :spec (rest spec)))
+ (make-instance 'lhtml-template :spec spec))
(defmethod make-template ((kind (eql 'html)) (spec cons))
- (make-instance 'pt-template :spec (rest spec)))
+ (make-instance 'pt-template :spec spec))
(defmethod initialize-instance :after ((template lhtml-template) &key css-specifiers &allow-other-keys)
- (let ((specifiers-and-vars (or css-specifiers (template-spec template))))
+ (let ((specifiers-and-vars (or css-specifiers (rest (template-spec template)))))
(setf (slot-value template 'specifiers)
(parse-specifiers specifiers-and-vars 'lhtml-template))))
@@ -94,7 +94,7 @@
(#T(regexp+ "^[ ]+" ()) (list (make-instance 'css-descendant-selector :arg t :matcher (parse-css-specifier &rest))))
;; simple selector sequence
(#T(regexp+ "^(\\w+)" (?element-type)) (cons (make-instance 'css-type-selector :arg element-type) (parse-css-specifier &rest)))
- (#T(regexp+ "^[#](\\w+)" (?element-id)) (cons (make-instance 'css-id-selector :arg element-id) (parse-css-specifier &rest)))
+ (#T(regexp+ "^[#](\\w+)" (?id)) (cons (make-instance 'css-id-selector :arg id) (parse-css-specifier &rest)))
(#T(regexp+ "^[\\.](\\w+)" (?class)) (cons (make-instance 'css-class-selector :arg class) (parse-css-specifier &rest)))))
(defgeneric css-select (specifier document))
@@ -115,6 +115,9 @@
:when (consp element)
:nconc (css-collect-elements selector (cddr element)))))
+(defmethod css-select ((selector css-selector) (element string))
+ nil)
+
(defmethod css-select ((selector css-specifier) (document cons))
(css-collect-elements selector
;; Urg. I may be doing something wrong here. :P
@@ -131,7 +134,7 @@
(cadr (assoc attr (cadr element))))
(defmethod css-select ((selector css-id-selector) (element cons))
- (when (string= (lhtml-attr :element-id element) (selector-arg selector))
+ (when (string= (lhtml-attr :id element) (selector-arg selector))
element))
(defmethod css-select ((selector css-class-selector) (element cons))
@@ -165,6 +168,6 @@
(defgeneric css-selector:element-type (element element-type))
(defgeneric css-selector:class (element class))
-(defgeneric css-selector:element-id (element element-id))
+(defgeneric css-selector:id (element id))
|#