I see that a few versions ago that DOM->text_before() and DOM->text_after()
were deprecated and removed. Evidently, I've been going too long between
upgrades. The Changelog says
Mojo::DOM::text_{before,after} is DEPRECATED in favor of
Mojo::DOM::contents
but the recommended way is to get back the previous functionality is
either not clear or I'm just missing something. I.e., how do we grab a
subset of the contents AND do the smart whitespace-trimming on it (which is
still available in ->text and ->all_text but apparently only for the full
set of children). At the moment, my workaround is:
sub text_after {
my $node = shift;
my $after = Mojo::Collection->new;
while (($node=$node->next_sibling) && $node->node ne 'tag') {
next if $node->node eq 'comment';
push @$after, $node;
}
# cargo-cult programmming ****FIX****
return Mojo::DOM::_text($after->tree,0,1);
}
the last line being where I gave up trying to stick to the public API.
Clearly I shouldn't be relying on _text and this probably breaks in
circumstances I don't know about, but I'm not seeing a good alternative
that doesn't involve cut&pasting Mojo's whitespace-trimming code into my
world.
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.