Lucifier129 / react-lite

An implementation of React v15.x that optimizes for small script size
MIT License
1.73k stars 98 forks source link

Why does function returned from getEventHandler prevent from propagating event? #27

Closed CoderK closed 8 years ago

CoderK commented 8 years ago

I have a question about react-lite's event system. Why does function returned from getEventHandler prevent from propagating native event?

    var getEventHandler = function getEventHandler(handleEvent) {
        handleEvent = eventHandlerWrapper(handleEvent);
        return function (e) {
            e.stopPropagation(); // This makes some side effect.
            e.nativeEvent = e;
            return handleEvent.call(this, e);
        };
    };

I had attached native click event listener on document.body, but because of it, my event listener was never called. React doesn't do like that.

fritx commented 8 years ago

Related? https://github.com/Lucifier129/react-lite/issues/25 - binding event inside onClick prop (inconsistent with react)

CoderK commented 8 years ago

Thanks, I could understand why. It's for reducing cost of code, but It makes some side effects in one instances. ㅠ-ㅠ.

Lucifier129 commented 8 years ago

I will consider it, and try to make them coincident in next version of react-lite:-)

Lucifier129 commented 8 years ago

Hi all, react-lite v0.0.19 update the event-system from dom level0 to delegation, see it at: https://github.com/Lucifier129/react-lite/blob/master/src/event-system.js

@fritx I think binding event inside a event listener now will be called like regular react.

fritx commented 8 years ago

nice

CoderK commented 8 years ago

that sounds good!