Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does yui DOM-create method have a handler for the class named 'yui3-big-dummy'?

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'

like image 897
xiaohao Avatar asked Sep 14 '12 02:09

xiaohao


1 Answers

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);
like image 117
Dan Crews Avatar answered Nov 03 '22 22:11

Dan Crews