From 0769c7633f29e1a743bac6488e6186a576431ddd Mon Sep 17 00:00:00 2001 From: AleksandrZhukov Date: Sun, 17 Jun 2018 14:48:05 +0300 Subject: [PATCH] Fixed defineProperty error There is an error - TypeError: Attempting to change enumerable attribute of unconfigurable property. Function's name is not configurable in old browsers (IE or Safari). `Note that in non-standard, pre-ES2015 implementations the configurable attribute was false as well.` https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name I decided that name prop is not so important and we can neglect it --- src/Form.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Form.jsx b/src/Form.jsx index f63a182..0cbbefe 100644 --- a/src/Form.jsx +++ b/src/Form.jsx @@ -60,7 +60,9 @@ export default class Form extends (PureComponent || Component) { return wrapper; }; - Object.defineProperty(wrapper, 'name', { value: name, enumerable: true }); + if (Object.getOwnPropertyDescriptor(wrapper, 'name').configurable) { + Object.defineProperty(wrapper, 'name', { value: name, enumerable: true }); + } Object.assign(wrapper, { value: this.get(name), onChange: handler,