Blockly: Object.values not available in IE

Created on 11 Sep 2019  路  2Comments  路  Source: google/blockly

Describe the bug

No Object.values in IE:
see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values

We're making use of it here:
https://github.com/google/blockly/blob/develop/core/keyboard_nav/key_map.js#L121
and here:
https://github.com/google/blockly/blob/develop/core/keyboard_nav/key_map.js#L141

@alschmiedt FYI

To Reproduce


Steps to reproduce the behavior:

  1. Run the playground on IE.

Use Object.keys and then use the key to extract the value.

bug

Most helpful comment

Sounds like a great fit for the Object utils file that's just about to appear.

/**
 * Returns an array of a given object's own enumerable property values.
 * @param {!Object} obj Object containing values.
 * @return {!Array} Array of values.
 */
Blockly.utils.object.values = function(obj) {
  if (Object.values) {
    return Object.values(obj);
  }
  // Fallback for IE.
  return Object.keys(obj).map(function(e) {
    return obj[e];
  });
};

All 2 comments

Sounds like a great fit for the Object utils file that's just about to appear.

/**
 * Returns an array of a given object's own enumerable property values.
 * @param {!Object} obj Object containing values.
 * @return {!Array} Array of values.
 */
Blockly.utils.object.values = function(obj) {
  if (Object.values) {
    return Object.values(obj);
  }
  // Fallback for IE.
  return Object.keys(obj).map(function(e) {
    return obj[e];
  });
};

Fixed.,

Was this page helpful?
0 / 5 - 0 ratings