kraih/mojo — pull request #699 by kraih (2014-10-29 18:10:31+00:00)
Title: Deprecate Mojo::DOM::AUTOLOAD and Mojo::Collection::AUTOLOAD

I expect this to be a controversial pull request. While those two `AUTOLOAD` methods allow for some pretty nice shortcuts, like `$dom->find('not(p)')->strip` and `$dom->parse('

Test

')->div->b->to_string`, they can also be rather confusing for less experienced Perl programmers.

Especially the fact that `Mojo::DOM::AUTOLOAD` can return a single `Mojo::DOM` object, or a `Mojo::Collection` object containing `Mojo::DOM` objects, depending on the structure of the HTML/XML document, makes it pretty much impossible to use outside of one-liners. This is documented, but we regularly see questions about how to use it in non-trivial scripts anyhow.

Other problematic cases are the infamous `$dom->find('foo')->find('bar')` and `$dom->find('foo')->at('bar')`, with unexpected return values for anyone who hasn't spent a lot of time with the documentation.