Repository: sentsin/layui
File: src/modules/form.js (JavaScript)

Code before:
              elem.prop('readonly', true);
            }

            // 添加禁用状态时的 className
            if (disabled) {
              elem.addClass(DISABLED);
            }

            return elem;
          })();

          var titleElem = (function() {
            var elem = $('<div class="'+ TITLE +'"></div>');
            elem.append(inputElem);
            elem.append('<i class="layui-edge"></i>');
            return elem;
          })();

          var contentElem = (function() {
            var elem = $('<dl class="layui-anim layui-anim-upbit"></dl>');
            if (othis.find('optgroup')[0]) {
              elem.addClass('layui-select-group');
            }
            var content = function() {
              var arr = [];
              layui.each(othis.find('*'), function(index, item) {
                var tagName = item.tagName.toLowerCase();
                var dd = $('<dd lay-value=""></dd>');
                if (index === 0 && !item.value && tagName !== 'optgroup') {
                  dd.addClass('layui-select-tips');
                  dd.text($.trim(item.innerText || TIPS));
                  arr.push(dd.prop('outerHTML'));
                } else if(tagName === 'optgroup') {
                  var dt = $('<dt></dt>');
                  dt.text(item.label);
                  arr.push(dt.prop('outerHTML'));
                } else {
                  dd.attr('lay-value', item.value);
                  if (value === item.value) {
                    dd.addClass(THIS);
                  }
                  if (item.disabled) {
                    dd.addClass(DISABLED);
                  }
                  dd.text($.trim(item.innerText));
                  arr.push(dd.prop('outerHTML'));
                }
              });
              if (arr.length === 0) {
                arr.push('<dd lay-value="" class="'+ DISABLED +'">None</dd>');
              }

Review comment (suggestion):

可以顺便处理一下这个问题 https://github.com/layui/layui/issues/2336

```suggestion
              layui.each(othis.find('optgroup,option'), function(index, item) {
```

Code after:
              elem.prop('readonly', true);
            }

            // 添加禁用状态时的 className
            if (disabled) {
              elem.addClass(DISABLED);
            }

            return elem;
          })();

          var titleElem = (function() {
            var elem = $('<div class="'+ TITLE +'"></div>');
            elem.append(inputElem);
            elem.append('<i class="layui-edge"></i>');
            return elem;
          })();

          var contentElem = (function() {
            var elem = $('<dl class="layui-anim layui-anim-upbit"></dl>');
            if (othis.find('optgroup')[0]) {
              elem.addClass('layui-select-group');
            }
            var content = function() {
              var arr = [];
              layui.each(othis.find('optgroup,option'), function(index, item) {
                var tagName = item.tagName.toLowerCase();
                var dd = $('<dd lay-value=""></dd>');
                if (index === 0 && !item.value && tagName !== 'optgroup') {
                  dd.addClass('layui-select-tips');
                  dd.text($.trim(item.innerText || TIPS));
                  arr.push(dd.prop('outerHTML'));
                } else if(tagName === 'optgroup') {
                  var dt = $('<dt></dt>');
                  dt.text(item.label);
                  arr.push(dt.prop('outerHTML'));
                } else {
                  dd.attr('lay-value', item.value);
                  if (value === item.value) {
                    dd.addClass(THIS);
                  }
                  if (item.disabled) {
                    dd.addClass(DISABLED);
                  }
                  dd.text($.trim(item.innerText));
                  arr.push(dd.prop('outerHTML'));
                }
              });
              if (arr.length === 0) {
                arr.push('<dd lay-value="" class="'+ DISABLED +'">None</dd>');
              }