From d978f126b9847f45f17f4bd8419236a99bfe99a9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 29 Mar 2013 21:38:11 +0000 Subject: Pull out function for comparing style parts with HTML elements --- lib/html-generator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/html-generator.js b/lib/html-generator.js index 5f2befa..8a67e53 100644 --- a/lib/html-generator.js +++ b/lib/html-generator.js @@ -24,7 +24,7 @@ function HtmlGenerator() { }); var partIndex = 0; - while (partIndex < firstFreshPartIndex && style[partIndex].tagName === stack[partIndex]) { + while (partIndex < firstFreshPartIndex && stylePartMatchesHtmlElement(style[partIndex], stack[partIndex])) { partIndex++; } while (stack.length > partIndex) { @@ -35,6 +35,10 @@ function HtmlGenerator() { } } + function stylePartMatchesHtmlElement(stylePart, htmlElement) { + return stylePart.tagName === htmlElement; + } + function push(element) { stack.push(element); fragments.push(util.format("<%s>", element)); -- cgit v1.2.3