Not sure if this is intentionally different from jQuery. It means you have to find the node you just inserted, because it's not the node you supplied, which is inconvenient.
jQuery example:
<!doctype html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#two').after($('#one'));
});
</script>
</head>
<body>
<p id="one">one</p>
<p id="two">two</p>
</body>
</html>output:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#two').after($('#one'));
});
</script>
</head>
<body>
<p id="two">two</p><p id="one">one</p>
</body></html>QueryPath example:
<?php
require('QueryPath/QueryPath.php');
$template = <<<DONE
<!doctype html>
<html>
<head>
</head>
<body>
<p id="one">one</p>
<p id="two">two</p>
</body>
</html>
DONE;
$doc = qp($template);
$one = $doc->branch()->find('#one');
$two = $doc->find('#two');
$two->after($one);
$doc->writeHTML();
?>Output:
<!DOCTYPE html>
<html><head></head><body>
<p id="one">one</p>
<p id="two">two</p><p id="one">one</p>
</body></html>
Comments
Comment #1
mbutcher commentedIt was an intentional decision at the time. I should look at it to see if we can fix it now, though.
Technically, this is an issue with the QueryPath library, which is maintained separately from this module. Can you post this as an issue in the QueryPath issue queue at https://github.com/technosophos/querypath ?