@@ -45,7 +45,7 @@ const onChangeInputType = type =>
4545 ) . test ( type ) ;
4646
4747// Some libraries like `react-virtualized` explicitly check for this.
48- Component . prototype . isReactComponent = { } ;
48+ Component . prototype . isReactComponent = true ;
4949
5050// `UNSAFE_*` lifecycle hooks
5151// Preact only ever invokes the unprefixed methods.
@@ -105,24 +105,17 @@ let oldEventHook = options.event;
105105options . event = e => {
106106 if ( oldEventHook ) e = oldEventHook ( e ) ;
107107
108- e . persist = empty ;
109- e . isPropagationStopped = isPropagationStopped ;
110- e . isDefaultPrevented = isDefaultPrevented ;
108+ e . persist = ( ) => { } ;
109+ e . isPropagationStopped = function isPropagationStopped ( ) {
110+ return this . cancelBubble ;
111+ } ;
112+ e . isDefaultPrevented = function isDefaultPrevented ( ) {
113+ return this . defaultPrevented ;
114+ } ;
111115 return ( e . nativeEvent = e ) ;
112116} ;
113117
114- function empty ( ) { }
115-
116- function isPropagationStopped ( ) {
117- return this . cancelBubble ;
118- }
119-
120- function isDefaultPrevented ( ) {
121- return this . defaultPrevented ;
122- }
123-
124118const classNameDescriptorNonEnumberable = {
125- enumerable : false ,
126119 configurable : true ,
127120 get ( ) {
128121 return this . class ;
@@ -132,9 +125,9 @@ const classNameDescriptorNonEnumberable = {
132125function handleDomVNode ( vnode ) {
133126 let props = vnode . props ,
134127 type = vnode . type ,
135- normalizedProps = { } ;
128+ normalizedProps = { } ,
129+ isNonDashedType = type . indexOf ( '-' ) == - 1 ;
136130
137- let isNonDashedType = type . indexOf ( '-' ) === - 1 ;
138131 for ( let i in props ) {
139132 let value = props [ i ] ;
140133
@@ -198,30 +191,28 @@ function handleDomVNode(vnode) {
198191 normalizedProps [ i ] = value ;
199192 }
200193
201- // Add support for array select values: <select multiple value={[]} />
202- if (
203- type == 'select' &&
204- normalizedProps . multiple &&
205- Array . isArray ( normalizedProps . value )
206- ) {
207- // forEach() always returns undefined, which we abuse here to unset the value prop.
208- normalizedProps . value = toChildArray ( props . children ) . forEach ( child => {
209- child . props . selected =
210- normalizedProps . value . indexOf ( child . props . value ) != - 1 ;
211- } ) ;
212- }
213-
214- // Adding support for defaultValue in select tag
215- if ( type == 'select' && normalizedProps . defaultValue != null ) {
216- normalizedProps . value = toChildArray ( props . children ) . forEach ( child => {
217- if ( normalizedProps . multiple ) {
218- child . props . selected =
219- normalizedProps . defaultValue . indexOf ( child . props . value ) != - 1 ;
220- } else {
194+ if ( type == 'select' ) {
195+ // Add support for array select values: <select multiple value={[]} />
196+ if ( normalizedProps . multiple && Array . isArray ( normalizedProps . value ) ) {
197+ // forEach() always returns undefined, which we abuse here to unset the value prop.
198+ normalizedProps . value = toChildArray ( props . children ) . forEach ( child => {
221199 child . props . selected =
222- normalizedProps . defaultValue == child . props . value ;
223- }
224- } ) ;
200+ normalizedProps . value . indexOf ( child . props . value ) != - 1 ;
201+ } ) ;
202+ }
203+
204+ // Adding support for defaultValue in select tag
205+ if ( normalizedProps . defaultValue != null ) {
206+ normalizedProps . value = toChildArray ( props . children ) . forEach ( child => {
207+ if ( normalizedProps . multiple ) {
208+ child . props . selected =
209+ normalizedProps . defaultValue . indexOf ( child . props . value ) != - 1 ;
210+ } else {
211+ child . props . selected =
212+ normalizedProps . defaultValue == child . props . value ;
213+ }
214+ } ) ;
215+ }
225216 }
226217
227218 if ( props . class && ! props . className ) {
0 commit comments