From 5d12564ff6297f1d21491bdc51066d26d8312e7a Mon Sep 17 00:00:00 2001 From: Chris Blake Date: Mon, 7 Mar 2016 14:07:21 -0500 Subject: [PATCH] Fixes listener adding error. Prior, all listeners were attached to the `attribute` object, instead of the `attributes.listeners` object. So adding a click listener would result in `attributes.click` existing, instead of `attributes.listeners.click`. This patch fixes this. --- dist/lmth.min.js | 2 +- lib/index.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/lmth.min.js b/dist/lmth.min.js index 9eba702..2c43d76 100644 --- a/dist/lmth.min.js +++ b/dist/lmth.min.js @@ -5,7 +5,7 @@ default:return!1}}function n(e){return"[object Object]"===toString.call(e)}funct r?r.push(t):n[e]=[].concat(t)}function o(e){var t={id:null,"class":[],style:null,listeners:{}} if(i(e)){var r=e.split(/([#\.][^#\.]+)/) r.forEach(function(e){e.startsWith("#")?t.id=e.substring(1):e.startsWith(".")&&t["class"].push(e.substring(1))})}else n(e)&&(Object.keys(e).forEach(function(n){var r=e[n] -n.startsWith("on")&&("function"==typeof r||Array.isArray(r))?s(n.slice(2),r,t):t[n]=r}),Array.isArray(t["class"])||(t["class"]=t["class"].split(" "))) +n.startsWith("on")&&("function"==typeof r||Array.isArray(r))?s(n.slice(2),r,t.listeners):t[n]=r}),Array.isArray(t["class"])||(t["class"]=t["class"].split(" "))) return t}function a(e){return String(e).replace(/&|<|>|"|'/g,function(e){switch(e){case"&":return"&" case"<":return"<" case">":return">" diff --git a/lib/index.js b/lib/index.js index e6d7ab5..7aa7d86 100644 --- a/lib/index.js +++ b/lib/index.js @@ -117,7 +117,7 @@ function parseAttributes(attributes) { if (attribute.startsWith('on') && (typeof(property) === 'function' || Array.isArray(property))) { - addListener(attribute.slice(2), property, nodeAttributes); + addListener(attribute.slice(2), property, nodeAttributes.listeners); } else { nodeAttributes[attribute] = property; } diff --git a/package.json b/package.json index f04bfa5..8af29ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lmth", - "version": "5.0.0-rc1", + "version": "5.0.0-rc2", "description": "A \"type-safe\" HTML DSL for JavaScript environments.", "main": "lib/index.js", "scripts": {