(in-package #:oh-ducks.traversal) (defmethod unify::occurs-in-p ((var symbol) (pat chtml:pt) env) (declare (ignore var pat env)) nil) ;;; general accessors (defmethod element-children ((element chtml:pt)) (remove-if (compose (rcurry #'member '(:pcdata :comment) :test #'eq) #'chtml:pt-name) (chtml:pt-children element))) (defmethod element-parent ((element chtml:pt)) (chtml:pt-parent element)) (defmethod element-attribute ((element-attribute symbol) (element chtml:pt)) (getf (chtml:pt-attrs element) element-attribute)) (defmethod element-attribute ((element-attribute string) (element chtml:pt)) (element-attribute (intern (string-upcase element-attribute) :keyword) element)) (defmethod element-type ((element chtml:pt)) (chtml:pt-name element)) (defmethod element-content ((element chtml:pt)) (mapcar (lambda (node) (cond ((eq :pcdata (chtml:pt-name node)) (chtml:pt-attrs node)) (t node))) (remove-if (curry #'eq :comment) (chtml:pt-children element) :key #'chtml:pt-name)))