Fix document detection.

Andrew LGTMs in person.
This commit is contained in:
Neil Fraser
2018-01-08 15:10:14 -08:00
parent dba896b78a
commit 870f7b7f8a
3 changed files with 5 additions and 5 deletions

View File

@@ -564,12 +564,12 @@ Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN = {
* @readonly
*/
Blockly.Constants.Logic.LOGIC_COMPARE_EXTENSION = function() {
// Fix operator labels in RTL
// Fix operator labels in RTL.
if (this.RTL) {
Blockly.Constants.Logic.fixLogicCompareRtlOpLabels.apply(this);
}
// Add onchange handler to ensure types are compatable.
// Add onchange handler to ensure types are compatible.
this.mixin(Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN);
};

View File

@@ -328,7 +328,7 @@ Blockly.Extensions.buildTooltipForDropdown = function(dropdownName,
// Wait for load, in case Blockly.Msg is not yet populated.
// runAfterPageLoad() does not run in a Node.js environment due to lack of
// document object, in which case skip the validation.
if (document) { // Relies on document.readyState
if (typeof document == 'object') { // Relies on document.readyState
Blockly.utils.runAfterPageLoad(function() {
for (var key in lookupTable) {
// Will print warnings if reference is missing.
@@ -409,7 +409,7 @@ Blockly.Extensions.buildTooltipWithFieldValue = function(msgTemplate,
// Wait for load, in case Blockly.Msg is not yet populated.
// runAfterPageLoad() does not run in a Node.js environment due to lack of
// document object, in which case skip the validation.
if (document) { // Relies on document.readyState
if (typeof document == 'object') { // Relies on document.readyState
Blockly.utils.runAfterPageLoad(function() {
// Will print warnings if reference is missing.
Blockly.utils.checkMessageReferences(msgTemplate);

View File

@@ -896,7 +896,7 @@ Blockly.utils.insertAfter_ = function(newNode, refNode) {
* @throws Error Will throw if no global document can be found (e.g., Node.js).
*/
Blockly.utils.runAfterPageLoad = function(fn) {
if (!document) {
if (typeof document != 'object') {
throw new Error('Blockly.utils.runAfterPageLoad() requires browser document.');
}
if (document.readyState === 'complete') {