jhy/jsoup — pull request #479 by hannibal218bc (2014-10-18 20:26:26+00:00)
Title: Element.classNames() must not be cached

Follow-up to request#478, now with test case and clean commit history. Sorry for the noise, still learning to use git :-/

Element.classNames() previously prepared the class name set just once and cached it. Hence, the returned set does not reflect later changes to the "class" attribute, neither through attr("class", "newclass") nor through classNames(newSet).

Since the caching behaviour is not documented, I believe the correct result would be to always return the latest class name set. This change removes the cached map and always prepares the class name set from scratch. Applications calling classNames() often may hit a performance penalty.

For the future, Element.classNames() could be improved to return an unmodifyable Set. Previously, changes to the returned set were refelected in the cached(!) set as well...