Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Apr 4, 2024
1 parent a6774c6 commit a7d9b35
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const html = (literals, ...expressions) => {
let accumulator = "";

for (let index = 0; index < expressions.length; ++index) {
const expression =
let literal = literals.raw[index];
let expression =
typeof expressions[index] === "string"
? expressions[index]
: expressions[index] == null
Expand All @@ -33,16 +34,13 @@ const html = (literals, ...expressions) => {
? expressions[index].join("")
: `${expressions[index]}`;

if (
literals.raw[index].length &&
literals.raw[index].charCodeAt(literals.raw[index].length - 1) === 33
) {
accumulator += literals.raw[index].slice(0, -1) + expression;
continue;
if (literal.length && literal.charCodeAt(literal.length - 1) === 33) {
literal = literal.slice(0, -1);
} else if (expression.length) {
expression = expression.replace(escapeRegExp, escapeFunction);
}

accumulator +=
literals.raw[index] + expression.replace(escapeRegExp, escapeFunction);
accumulator += literal + expression;
}

accumulator += literals.raw[expressions.length];
Expand Down

0 comments on commit a7d9b35

Please # to comment.