6

In the YUI documentation; http://yuilibrary.com/yui/docs/api/files/dom_js_dom-create.js.html

if (nodes.length === 1) { // return single node, breaking parentNode ref from "fragment"
            ret = nodes[0].parentNode.removeChild(nodes[0]);
        } else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected)
            if (nodes.length === 2) {
                ret = nodes[0].nextSibling;
            } else {
                nodes[0].parentNode.removeChild(nodes[0]); 
                ret = Y_DOM._nl2frag(nodes, doc);
            }
        } else { // return multiple nodes as a fragment
             ret = Y_DOM._nl2frag(nodes, doc);
        }

Line 110 says that

} else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected)

What does this mean exactly? I don't understand why there is be a class named 'yui3-big-dummy'

Jack
  • 1,603
  • 5
  • 25
  • 36
xiaohao
  • 272
  • 1
  • 7

1 Answers1

2

It's because they use that class further down on their own internal stuff, and they just don't want to stick a class there that someone will actually use. You'll notice down on line 317 that they're putting some stuff in there using that class, and they're trying to target that. It's just some internal stuff that you generally won't have to worry about.

return Y_DOM.create('<select><option class="yui3-big-dummy" selected></option>' + html + '</select>', doc);
Dan Crews
  • 3,067
  • 17
  • 20
  • em, thanks. but target that to do what? it's confusing...and is there any detail how "yui3-big-dummy" is used ? forgive my curiosity – xiaohao Sep 17 '12 at 02:37
  • In the comments they note "using dummy node to preserve some attributes (e.g. OPTION not selected)". That's likely what they're doing. – Kevin Lamping Sep 19 '12 at 14:13