cgrand/enlive

void selector is whitespace-sensitive

gtebbutt opened this issue · 2 comments

Possibly expected behaviour, but it seemed worth mentioning: the void selector currently excludes nodes which contain only whitespace (where a CSS :empty selector would match).

[[:div#menu void]]

matches:

<div id="menu"></div>

but not:

    <div id="menu">
    </div>

The fix is very simple:

(def void (pred #(empty? (remove empty? (map clojure.string/trim (:content %))))))

Good point! SGML states that these two snippets are equivalent. Nevertheless your fix may break existing programs that coped with this "feature", so we'll consider it for a major version.
Thankies!

What about adding a dedicated whitespace ou whitespace-only selector? (and cross document the new selector and void)