electrum-events
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -20,3 +20,3 @@ 'use strict'; | ||
var EventHandlers = (function () { | ||
function EventHandlers(props, bus) { | ||
function EventHandlers(props, bus, valueGetter) { | ||
_classCallCheck(this, EventHandlers); | ||
@@ -32,2 +32,5 @@ | ||
} | ||
this._valueGetter = valueGetter || function (t) { | ||
return t.value; | ||
}; | ||
} | ||
@@ -112,3 +115,3 @@ | ||
var states = (0, _getTextSelection2.default)(target); | ||
bus.notify(this._props, target.value, states); | ||
bus.notify(this._props, this._valueGetter(target), states); | ||
} | ||
@@ -137,3 +140,5 @@ } | ||
value: function inject(obj, props, bus) { | ||
var eh = new EventHandlers(props, bus); | ||
var eh = new EventHandlers(props, bus, obj.getValue && function (e) { | ||
return obj.getValue(e.target); | ||
}); | ||
/* jshint expr: true */ | ||
@@ -140,0 +145,0 @@ var existingOnFocus = obj.onFocus; |
{ | ||
"name": "electrum-events", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Electrum Events forwards web component events to the bus.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -8,3 +8,3 @@ 'use strict'; | ||
export default class EventHandlers { | ||
constructor (props, bus) { | ||
constructor (props, bus, valueGetter) { | ||
this._props = props; | ||
@@ -16,2 +16,3 @@ if (typeof bus === 'function') { | ||
} | ||
this._valueGetter = valueGetter || (t => t.value); | ||
} | ||
@@ -56,3 +57,3 @@ | ||
static inject (obj, props, bus) { | ||
const eh = new EventHandlers (props, bus); | ||
const eh = new EventHandlers (props, bus, obj.getValue && (e => obj.getValue (e.target))); | ||
/* jshint expr: true */ | ||
@@ -105,3 +106,3 @@ const existingOnFocus = obj.onFocus; | ||
const states = getTextSelection (target); | ||
bus.notify (this._props, target.value, states); | ||
bus.notify (this._props, this._valueGetter (target), states); | ||
} | ||
@@ -108,0 +109,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
20704
398