X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-utils.js;h=63411a599627809693bf15837ee47d466558f39c;hb=f57d599bf6626436e963f58e4b4468fabbc3580a;hp=c6c3a60345712b76cd023fa212011b3fb0611c17;hpb=e26b71566419e1c051f3fbd1f4f8f64b063a04c9;p=dygraphs.git diff --git a/dygraph-utils.js b/dygraph-utils.js index c6c3a60..63411a5 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -147,6 +147,21 @@ Dygraph.addEvent = function addEvent(elem, type, fn) { /** * @private + * Add an event handler. This event handler is kept until the graph is + * destroyed with a call to graph.destroy(). + * + * @param { DOM element } elem The element to add the event to. + * @param { String } type The type of the event, e.g. 'click' or 'mousemove'. + * @param { Function } fn The function to call on the event. The function takes + * one parameter: the event object. + */ +Dygraph.prototype.addEvent = function addEvent(elem, type, fn) { + Dygraph.addEvent(elem, type, fn); + this.registeredEvents_.push({ elem : elem, type : type, fn : fn }); +}; + +/** + * @private * Remove an event handler. This smooths a difference between IE and the rest of * the world. * @param { DOM element } elem The element to add the event to. @@ -583,7 +598,7 @@ Dygraph.updateDeep = function (self, o) { // DOM objects are shallowly-copied. self[k] = o[k]; } else if (typeof(o[k]) == 'object') { - if (typeof(self[k]) != 'object') { + if (typeof(self[k]) != 'object' || self[k] === null) { self[k] = {}; } Dygraph.updateDeep(self[k], o[k]);