DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
    • can-control
    • can-event
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
    • can-simple-map
    • can-util
      • can-util/dom
        • ./ajax/
        • ./attr/
        • ./child-nodes/
        • ./class-name/
        • ./data/
        • ./dispatch/
        • ./document/
        • ./events/
        • ./frag/
        • ./mutate/
      • can-util/js
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-util
  • /
  • can-util/dom
  • /
  • ./frag/
  • / On this page
    • frag

      module

      Convert a String, HTMLElement, documentFragment, or contentArray into a documentFragment.

      • source

      frag: function(item, doc)

      Parameters

      1. item {String|HTMLElement|documentFragment|contentArray}:
      2. doc {Document}:

        an optional DOM document in which to build the fragment

      Returns

      {documentFragment}:

      Use

      ContentArrays can be used to combine multiple HTMLElements into a single document fragment. For example:

      var p = document.createElement("p");
      p.innerHTML = "Welcome to <b>CanJS</b>";
      var contentArray = ["<h1>Hi There</h1>", p];
      var fragment = frag( contentArray )
      

      fragment will be a documentFragment with the following elements:

      <h1>Hi There</h1>
      <p>Welcome to <b>CanJS</b></p>
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.