From 0273f2557e9932a31ba22152e42fddf59591daef Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 7 Mar 2014 09:35:41 -0500 Subject: [PATCH] Support element attributes as intended --- dom-driver.js | 6 ++++++ examples/dom/index.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dom-driver.js b/dom-driver.js index 2275784..c9434f2 100644 --- a/dom-driver.js +++ b/dom-driver.js @@ -61,7 +61,13 @@ DOMFragment.prototype.interpretSpec = function (spec) { var attrs = hasAttrs ? spec[1] : {}; var kidIndex = hasAttrs ? 2 : 1; + // Wow! Such XSS! Many hacks! So vulnerability! Amaze! var n = document.createElement(tagName); + for (var attr in attrs) { + if (attrs.hasOwnProperty(attr)) { + n.setAttribute(attr, attrs[attr]); + } + } for (var i = kidIndex; i < spec.length; i++) { n.appendChild(this.interpretSpec(spec[i])); } diff --git a/examples/dom/index.js b/examples/dom/index.js index 8e88d0a..31beb72 100644 --- a/examples/dom/index.js +++ b/examples/dom/index.js @@ -12,7 +12,7 @@ $(document).ready(function () { } } }, [pub(["DOM", "#clicker-holder", "clicker", - ["button", "Click me!"]]), + ["button", ["span", {"style": "font-style: italic"}, "Click me!"]]]), pub("bump_count"), sub(["jQuery", "button.clicker", "click", __])]);