react-faux-dom
Advanced tools
Comparing version 1.1.0 to 2.0.0
{ | ||
"name": "react-faux-dom", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "DOM like data structure to be mutated by D3 et al, then rendered to React elements", | ||
@@ -32,10 +32,13 @@ "main": "src/ReactFauxDOM.js", | ||
"faucet": "0.0.1", | ||
"nodemon": "^1.6.1", | ||
"react": "^0.13.3", | ||
"nodemon": "^1.7.1", | ||
"react": "^0.14.0", | ||
"sinon": "^1.17.1", | ||
"standard": "^5.1.0", | ||
"tape": "^4.2.0" | ||
"tape": "^4.2.1" | ||
}, | ||
"dependencies": { | ||
"lodash.assign": "^3.2.0", | ||
"lodash.camelcase": "^3.0.1", | ||
"lodash.clone": "^3.0.3", | ||
"lodash.mapvalues": "^3.0.1", | ||
"query-selector": "^1.0.9", | ||
@@ -45,4 +48,4 @@ "style-attr": "^1.0.1" | ||
"peerDependencies": { | ||
"react": "0.x" | ||
"react": "*" | ||
} | ||
} |
@@ -5,2 +5,4 @@ var React = require('react') | ||
var camelCase = require('lodash.camelcase') | ||
var assign = require('lodash.assign') | ||
var mapValues = require('lodash.mapvalues') | ||
var querySelectorAll = require('query-selector') | ||
@@ -12,2 +14,3 @@ | ||
this.children = [] | ||
this.eventListeners = {} | ||
this.text = '' | ||
@@ -119,7 +122,17 @@ var props = this.props = { | ||
Element.prototype.addEventListener = function (name, fn) { | ||
this.props[this.eventToPropName(name)] = fn | ||
var prop = this.eventToPropName(name) | ||
this.eventListeners[prop] = this.eventListeners[prop] || [] | ||
this.eventListeners[prop].push(fn) | ||
} | ||
Element.prototype.removeEventListener = function (name, fn) { | ||
delete this.props[this.eventToPropName(name)] | ||
var listeners = this.eventListeners[this.eventToPropName(name)] | ||
if (listeners) { | ||
var match = listeners.indexOf(fn) | ||
if (match !== -1) { | ||
listeners.splice(match, 1) | ||
} | ||
} | ||
} | ||
@@ -224,2 +237,17 @@ | ||
assign(props, mapValues(this.eventListeners, function (listeners) { | ||
return function (syntheticEvent) { | ||
var event | ||
if (syntheticEvent) { | ||
event = syntheticEvent.nativeEvent | ||
event.syntheticEvent = syntheticEvent | ||
} | ||
mapValues(listeners, function (listener) { | ||
listener(event) | ||
}) | ||
} | ||
})) | ||
return React.createElement(this.nodeName, props, this.text || this.children.map(function (el, i) { | ||
@@ -226,0 +254,0 @@ if (el instanceof Element) { |
@@ -55,3 +55,3 @@ var test = require('tape') | ||
t.plan(1) | ||
t.equal(typeof el.props.onMouseOver, 'function') | ||
t.equal(typeof el.eventListeners.onMouseOver[0], 'function') | ||
}) | ||
@@ -58,0 +58,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24130
18
574
7
7
+ Addedlodash.assign@^3.2.0
+ Addedlodash.mapvalues@^3.0.1
+ Addedlodash._basecallback@3.3.1(transitive)
+ Addedlodash._baseisequal@3.0.7(transitive)
+ Addedlodash._createassigner@3.1.1(transitive)
+ Addedlodash.assign@3.2.0(transitive)
+ Addedlodash.istypedarray@3.0.6(transitive)
+ Addedlodash.mapvalues@3.0.1(transitive)
+ Addedlodash.pairs@3.0.1(transitive)
+ Addedlodash.restparam@3.6.1(transitive)
+ Addedreact@19.0.0(transitive)
- Removedacorn@5.7.4(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedasap@2.0.6(transitive)
- Removedast-types@0.9.6(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase62@1.2.8(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcommoner@0.10.8(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcore-js@1.2.7(transitive)
- Removeddefined@1.0.1(transitive)
- Removeddetective@4.7.1(transitive)
- Removedenvify@3.4.1(transitive)
- Removedesprima@3.1.3(transitive)
- Removedesprima-fb@15001.1.0-dev-harmony-fb(transitive)
- Removedfbjs@0.6.1(transitive)
- Removedglob@5.0.15(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjstransform@11.0.3(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedobject-assign@2.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedprivate@0.1.8(transitive)
- Removedpromise@7.3.1(transitive)
- Removedq@1.5.1(transitive)
- Removedreact@0.14.10(transitive)
- Removedrecast@0.11.23(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsource-map@0.4.40.5.7(transitive)
- Removedthrough@2.3.8(transitive)
- Removedua-parser-js@0.7.40(transitive)
- Removedwhatwg-fetch@0.9.0(transitive)
- Removedwrappy@1.0.2(transitive)