From aac776b1711d1e286812035a28108c622e73994a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 13 Oct 2015 22:10:42 +0100 Subject: Add simplification of nodes --- lib/html/ast.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/html/ast.js') diff --git a/lib/html/ast.js b/lib/html/ast.js index 25f4874..afecfce 100644 --- a/lib/html/ast.js +++ b/lib/html/ast.js @@ -1,5 +1,8 @@ var _ = require("underscore"); +var htmlPaths = require("../html-paths"); + + function fragment(children) { return { type: "fragment", @@ -8,10 +11,15 @@ function fragment(children) { } function element(tagName, attributes, children) { + return elementWithTag( + htmlPaths.element(tagName, attributes, {fresh: true}), + children); +} + +function elementWithTag(tag, children) { return { type: "element", - tagName: tagName, - attributes: attributes, + tag: tag, children: collapseFragments(children) }; } @@ -31,4 +39,5 @@ function collapseFragments(elements) { exports.fragment = fragment; exports.element = element; +exports.elementWithTag = elementWithTag; exports.text = text; -- cgit v1.2.3