Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
fix(ceb-templating-literal): attribute name with matching value shoul…
Browse files Browse the repository at this point in the history
…d not be handled as boolean
  • Loading branch information
tmorin committed Nov 10, 2021
1 parent 3406fe5 commit 8b37edf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/ceb-templating-literal/src/literal.attribute.spec.ts
Expand Up @@ -11,14 +11,14 @@ describe("literal/attribute", function () {
})
it("should parse attributes", function () {
const value = 1
const template = html`<p><input required disabled="" type="number" value="${value}" ></p>`
const template = html`<p><input name="name" required disabled="" type="number" value="${value}"></p>`
template.render(el)
expect(el.innerHTML).to.be.eq(`<p><input required="" disabled="" type="number" value="1"></p>`)
expect(el.innerHTML).to.be.eq(`<p><input name="name" required="" disabled="" type="number" value="1"></p>`)
})
it("should parse complex attributes", function () {
const foo = "foo"
const bar = "bar"
const template = html`<p><input type="text" name="${foo}" value="before ${bar} after" ></p>`
const template = html`<p><input type="text" name="${foo}" value="before ${bar} after"></p>`
template.render(el)
expect(el.innerHTML).to.be.eq(`<p><input type="text" name="foo" value="before bar after"></p>`)
})
Expand Down
Expand Up @@ -20,7 +20,7 @@ describe("literal/complex", function () {
template.render(el)
expect(el.innerHTML).to.be.eq(`<ul><li>header</li><li>itemA</li><li>itemB</li><li>itemC</li><li>footer</li></ul>`)
})
it.only("should handle a bulma card", function () {
it("should handle a bulma card", function () {
let cardName = "The name of the card"
let cardDescription = "The description of the card."
const template = html`
Expand Down
3 changes: 1 addition & 2 deletions packages/ceb-templating-literal/src/literal.ts
Expand Up @@ -80,8 +80,7 @@ function generateParameters(tagAttrs: Array<Attribute> = [], args: Array<any>):
})
}
} else {
const sanitizedAttrValue = value === attrName ? "" : value
attributes.push([attrName, sanitizedAttrValue])
attributes.push([attrName, value])
}
})
return {attributes, properties, options}
Expand Down

0 comments on commit 8b37edf

Please sign in to comment.