How to convert an array of `DOMNode`s to a `DOMQuery` that holds exactly those nodes?

6 Views Asked by At

What is the idiomatic, efficient technique to construct a DOMQuery object that will contain the exact, caller-provided sequence of DOMNode objects? Detailed requirements:

  • the DOMNode objects in the resulting collection must be the same objects as those provided; cloning of nodes is undesirable
  • the method should be as efficient as possible

Things that don't work:

  • (new DOMQuery())->append($firstNode)->append($secondNode)... will append to the elements of the collection, rather than to the collection itself

  • new DOMQuery($firstNode) only works with one node, and there seems to be no way to add more nodes

  • anything that involves DOMDocumentFragment launches its own horror story arc with a lot of predicted StackOverflow traffic

So, how do I?

0

There are 0 best solutions below