From 455e5110511674a840403e103ee15f70b154f0b9 Mon Sep 17 00:00:00 2001 From: Isiah Meadows Date: Sun, 15 Mar 2020 16:36:06 -0700 Subject: [PATCH] Fix #2257 --- render/render.js | 1 + render/tests/test-event.js | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/render/render.js b/render/render.js index 7e6e62f97..fdf90cd37 100644 --- a/render/render.js +++ b/render/render.js @@ -897,6 +897,7 @@ module.exports = function($window) { //event function updateEvent(vnode, key, value) { if (vnode.events != null) { + vnode.events._ = currentRedraw if (vnode.events[key] === value) return if (value != null && (typeof value === "function" || typeof value === "object")) { if (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false) diff --git a/render/tests/test-event.js b/render/tests/test-event.js index 8e650b91b..239a86747 100644 --- a/render/tests/test-event.js +++ b/render/tests/test-event.js @@ -5,14 +5,14 @@ var domMock = require("../../test-utils/domMock") var vdom = require("../../render/render") o.spec("event", function() { - var $window, root, redraw, render + var $window, root, redraw, render, reallyRender o.beforeEach(function() { $window = domMock() root = $window.document.body redraw = o.spy() - var renderer = vdom($window) + reallyRender = vdom($window) render = function(dom, vnode) { - return renderer(dom, vnode, redraw) + return reallyRender(dom, vnode, redraw) } }) @@ -355,4 +355,32 @@ o.spec("event", function() { o(redraw.this).equals(undefined) o(redraw.args.length).equals(0) }) + + o("handles changed spy", function() { + var div1 = {tag: "div", attrs: {ontransitionend: function() {}}} + + reallyRender(root, [div1], redraw) + var e = $window.document.createEvent("HTMLEvents") + e.initEvent("transitionend", true, true) + div1.dom.dispatchEvent(e) + + o(redraw.callCount).equals(1) + o(redraw.this).equals(undefined) + o(redraw.args.length).equals(0) + + var replacementRedraw = o.spy() + var div2 = {tag: "div", attrs: {ontransitionend: function() {}}} + + reallyRender(root, [div2], replacementRedraw) + var e = $window.document.createEvent("HTMLEvents") + e.initEvent("transitionend", true, true) + div2.dom.dispatchEvent(e) + + o(redraw.callCount).equals(1) + o(redraw.this).equals(undefined) + o(redraw.args.length).equals(0) + o(replacementRedraw.callCount).equals(1) + o(replacementRedraw.this).equals(undefined) + o(replacementRedraw.args.length).equals(0) + }) })