Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ReactART.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const Mode = require('art/modes/current');

const React = require('react');
const ReactDOM = require('react-dom');
const ReactInstanceMap = require('react/lib/ReactInstanceMap');
const ReactMultiChild = require('react/lib/ReactMultiChild');
const ReactUpdates = require('react/lib/ReactUpdates');
const ReactInstanceMap = require('react-dom/lib/ReactInstanceMap');
const ReactMultiChild = require('react-dom/lib/ReactMultiChild');
const ReactUpdates = require('react-dom/lib/ReactUpdates');

const emptyObject = require('fbjs/lib/emptyObject');
const invariant = require('fbjs/lib/invariant');
Expand Down Expand Up @@ -93,7 +93,7 @@ function injectAfter(parentNode, referenceNode, node) {

// ContainerMixin for components that can hold ART nodes

const ContainerMixin = assign({}, ReactMultiChild, {
const ContainerMixin = assign({}, ReactMultiChild.Mixin, {

/**
* Moves a child component to the supplied index.
Expand Down Expand Up @@ -278,7 +278,7 @@ const NodeMixin = {
listeners[type] = listener;
if (listener) {
if (!subscriptions[type]) {
subscriptions[type] = this.node.subscribe(type, listener, this);
subscriptions[type] = this.node.subscribe(type, this.handleEvent, this);
}
} else {
if (subscriptions[type]) {
Expand Down
29 changes: 29 additions & 0 deletions src/__tests__/ReactART-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,33 @@ describe('ReactART', function() {
expect(ref.constructor).toBe(CustomShape);
});

it('adds and updates event handlers', function() {
const container = document.createElement('div');

function render(onClick) {
return ReactDOM.render(
<Surface>
<Shape onClick={onClick} />
</Surface>,
container,
);
}

function doClick(instance) {
const path = ReactDOM.findDOMNode(instance).querySelector('path');

// ReactTestUtils.Simulate.click doesn't work with SVG elements
path.click();
}

const onClick1 = jest.fn();
let instance = render(onClick1);
doClick(instance);
expect(onClick1).toBeCalled();

const onClick2 = jest.fn();
instance = render(onClick2);
doClick(instance);
expect(onClick2).toBeCalled();
});
});