Why does the yui DOM-create method have a handler for a 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 (eg 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 a dummy node to save some attributes (for example, OPTION is not selected)

What does it mean? I do not understand why there is a class called "yui3-big-dummy"

+6
source share
1 answer

This is because they use this class further on their own internal things, and they simply do not want to stick to the class where someone will actually use it. On line 317, you will notice that they put some things there using this class, and they are trying to target. These are just some of the internal things that you don’t have to worry about at all.

 return Y_DOM.create('<select><option class="yui3-big-dummy" selected></option>' + html + '</select>', doc); 
+2
source

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


All Articles