defineProperties.js 804 B

123456789101112131415161718192021222324252627
  1. import defined from './defined.js';
  2. var definePropertyWorks = (function() {
  3. try {
  4. return 'x' in Object.defineProperty({}, 'x', {});
  5. } catch (e) {
  6. return false;
  7. }
  8. })();
  9. /**
  10. * Defines properties on an object, using Object.defineProperties if available,
  11. * otherwise returns the object unchanged. This function should be used in
  12. * setup code to prevent errors from completely halting JavaScript execution
  13. * in legacy browsers.
  14. *
  15. * @private
  16. *
  17. * @exports defineProperties
  18. */
  19. var defineProperties = Object.defineProperties;
  20. if (!definePropertyWorks || !defined(defineProperties)) {
  21. defineProperties = function(o) {
  22. return o;
  23. };
  24. }
  25. export default defineProperties;