Fix field dropdown with images (#4016)

* Fix field dropdown with images
This commit is contained in:
Sam El-Husseini
2020-07-06 10:55:00 -07:00
committed by GitHub
parent dca554c65a
commit 8f5966ec75

View File

@@ -20,15 +20,15 @@ goog.require('Blockly.utils.IdGenerator');
/**
* Class representing an item in a menu.
*
* @param {string} content Text caption to display as the content of
* the item.
* @param {string|!HTMLElement} content Text caption to display as the content
* of the item, or a HTML element to display.
* @param {string=} opt_value Data/model associated with the menu item.
* @constructor
*/
Blockly.MenuItem = function(content, opt_value) {
/**
* Human-readable text of this menu item.
* @type {string}
* Human-readable text of this menu item, or the HTML element to display.
* @type {string|!HTMLElement}
* @private
*/
this.content_ = content;
@@ -125,7 +125,11 @@ Blockly.MenuItem.prototype.createDom = function() {
content.appendChild(checkbox);
}
content.appendChild(document.createTextNode(this.content_));
var contentDom = /** @type {!HTMLElement} */ (this.content_);
if (typeof this.content_ == 'string') {
contentDom = document.createTextNode(this.content_);
}
content.appendChild(contentDom);
element.appendChild(content);
// Initialize ARIA role and state.