Creating a document fragment in YUI 3

I searched for documents for YUI3, but I cannot figure out how to create a fragment of a document. Should I just use the document object itself? I would like to consider it as a YUI Node object.

+3
source share
4 answers

If you want to create a new empty docfrag, this should work:

var frag = Y.all([]).toFrag();

frag is a Node instance terminating docfrag.

+6
source

I think this is equivalent to Luke's answer (I just find it more readable)

var frag = Y.one(document.createDocumentFragment());
+2
source
+1
var docFrag = Y.Node.create('<div id="foo"><p>Bar</p></div>');

Will work. Y.Node.create can do anything. Recently ran into this problem with very new versions of chrome, but simplified the job:

http://yuilibrary.com/projects/yui3/ticket/2529368

-1
source

Source: https://habr.com/ru/post/1779539/


All Articles