Skip to content

Commit 225cb9a

Browse files
committed
Fix for IE 10: does no support inheritance with static properties
1 parent e60b843 commit 225cb9a

File tree

1 file changed

+33
-2
lines changed
  • packages/react-form-with-constraints-bootstrap4/src

1 file changed

+33
-2
lines changed

packages/react-form-with-constraints-bootstrap4/src/Bootstrap.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import PropTypes from 'prop-types';
12
import {
2-
FormWithConstraints, Input as _Input,
3-
FieldFeedbacks, Async, FieldFeedback as _FieldFeedback, FieldFeedbackProps
3+
FormWithConstraints,
4+
Input as _Input, InputContext,
5+
FieldFeedbacks, Async,
6+
FieldFeedback as _FieldFeedback, FieldFeedbackProps, FieldFeedbackContext
47
} from 'react-form-with-constraints';
58

69
// ## Error
@@ -40,6 +43,16 @@ import {
4043
// see https://github.com/twbs/bootstrap/blob/v4.1.2/scss/_forms.scss#L245
4144

4245
export class FieldFeedback extends _FieldFeedback {
46+
// FIXME Copy-pasted from FieldFeedback to support IE <= 10
47+
// See ["__proto__ is not supported on IE <= 10 so static properties will not be inherited"](https://babeljs.io/docs/en/caveats#classes-10-and-below)
48+
// [@babel/plugin-transform-proto-to-assign](https://babeljs.io/docs/en/babel-plugin-transform-proto-to-assign) did not work
49+
static contextTypes: React.ValidationMap<FieldFeedbackContext> = {
50+
form: PropTypes.instanceOf(FormWithConstraints).isRequired,
51+
fieldFeedbacks: PropTypes.instanceOf(FieldFeedbacks).isRequired,
52+
async: PropTypes.instanceOf(Async)
53+
};
54+
context!: FieldFeedbackContext;
55+
4356
static defaultProps: FieldFeedbackProps = {
4457
// See https://github.com/facebook/react/issues/3725#issuecomment-169163998
4558
// See React.Component.defaultProps objects are overridden, not merged? https://stackoverflow.com/q/40428847
@@ -54,6 +67,16 @@ export class FieldFeedback extends _FieldFeedback {
5467
}
5568

5669
export class FieldFeedbackTooltip extends _FieldFeedback {
70+
// FIXME Copy-pasted from FieldFeedback to support IE <= 10
71+
// See ["__proto__ is not supported on IE <= 10 so static properties will not be inherited"](https://babeljs.io/docs/en/caveats#classes-10-and-below)
72+
// [@babel/plugin-transform-proto-to-assign](https://babeljs.io/docs/en/babel-plugin-transform-proto-to-assign) did not work
73+
static contextTypes: React.ValidationMap<FieldFeedbackContext> = {
74+
form: PropTypes.instanceOf(FormWithConstraints).isRequired,
75+
fieldFeedbacks: PropTypes.instanceOf(FieldFeedbacks).isRequired,
76+
async: PropTypes.instanceOf(Async)
77+
};
78+
context!: FieldFeedbackContext;
79+
5780
static defaultProps: FieldFeedbackProps = {
5881
// See https://github.com/facebook/react/issues/3725#issuecomment-169163998
5982
// See React.Component.defaultProps objects are overridden, not merged? https://stackoverflow.com/q/40428847
@@ -68,6 +91,14 @@ export class FieldFeedbackTooltip extends _FieldFeedback {
6891
}
6992

7093
export class Input extends _Input {
94+
// FIXME Copy-pasted from FieldFeedback to support IE <= 10
95+
// See ["__proto__ is not supported on IE <= 10 so static properties will not be inherited"](https://babeljs.io/docs/en/caveats#classes-10-and-below)
96+
// [@babel/plugin-transform-proto-to-assign](https://babeljs.io/docs/en/babel-plugin-transform-proto-to-assign) did not work
97+
static contextTypes: React.ValidationMap<InputContext> = {
98+
form: PropTypes.instanceOf(FormWithConstraints).isRequired
99+
};
100+
context!: InputContext;
101+
71102
static defaultProps = {
72103
classes: {
73104
isPending: 'is-pending',

0 commit comments

Comments
 (0)