Skip to content

Commit

Permalink
tags can now receive additional attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario T. Lanza committed May 8, 2024
1 parent e3a0ab2 commit 6111330
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,19 @@ function tags2(engine, keys){
return tags3(engine, _.identity, keys);
}

function tags3(engine, f, keys){
function tags3(engine, f, keys) {
const tag = _.factory(engine);
return _.fold(function(memo, key){
memo[key] = f(tag(key));
return memo;
}, {}, keys);
return keys
|> _.concat(?, [null])
|> _.scan(2, ?)
|> _.toArray
|> _.fold(function(memo, keys){
const [key, nextKey] = _.toArray(keys);
if (_.isString(key)) {
memo[key] = f(_.isArray(nextKey) ? _.isString(_.first(nextKey)) ? tag(...nextKey) : tag(key, ...nextKey) : tag(key));
}
return memo;
}, {}, ?);
}

export function svg(doc = document, tags = ["svg", "g", "symbol", "defs", "clipPath", "metadata", "path", "line", "circle", "rect", "ellipse", "polygon", "polyline", "image", "text", "tspan"]){
Expand Down

0 comments on commit 6111330

Please sign in to comment.