Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SelectEditor.prototype.open = function () {
var width = Handsontable.Dom.outerWidth(this.TD)
var height = Handsontable.Dom.outerHeight(this.TD)
var rootOffset = Handsontable.Dom.offset(this.instance.rootElement)
var tdOffset = Handsontable.Dom.offset(this.TD)
// sets <select> dimensions to match cell size
this.select.style.height = height + 'px'
this.select.style.width = width + 'px'
// make sure that </select> position matches cell position
this.select.style.top = tdOffset.top - rootOffset.top + 'px'
this.select.style.left = tdOffset.left - rootOffset.left + 'px'
this.select.style.margin = '0'
// display the <select>
this.select.style.display = ''
}</select>
Promise.resolve(optionsPromise).then(function (options) {
Handsontable.Dom.empty(context.select) // clear select of existing options
// Convert object to array of objects
if (typeof options === 'object' && !Array.isArray(options)) {
var optionsArray = []
for (var option in options) {
optionsArray.push({value: option, label: options[option]})
}
options = optionsArray
}
options.forEach(function (option) {
var label = option.label || option.value || option
var value = option.value || option.label || option
var optionEl = document.createElement('option')
optionEl.value = value
Handsontable.Dom.fastInnerHTML(optionEl, label)
SelectEditor.prototype.init = function () {
this.select = document.createElement('select')
Handsontable.Dom.addClass(this.select, 'select-editor')
this.select.style.display = 'none'
this.instance.rootElement.appendChild(this.select)
}
options.forEach(function (option) {
var label = option.label || option.value || option
var value = option.value || option.label || option
var optionEl = document.createElement('option')
optionEl.value = value
Handsontable.Dom.fastInnerHTML(optionEl, label)
this.select.appendChild(optionEl)
}, context)