Skip to content

Commit

Permalink
fix(ld-icon): replace icon instead of appending it on name change
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdiakur committed Nov 16, 2021
1 parent 1b53b7f commit 16605f0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions screenshot/builds/master.json
Original file line number Diff line number Diff line change
Expand Up @@ -4034,6 +4034,19 @@
"isLandscape": false,
"isMobile": false
},
{
"id": "1a6085ee",
"image": "bfbdc874abd3e1b63d6424c83049689d.png",
"userAgent": "default",
"desc": "ld-icon replaces existing icon on icon name change",
"testPath": "./src/liquid/components/ld-icon/test/ld-icon.e2e.ts",
"width": 600,
"height": 600,
"deviceScaleFactor": 1,
"hasTouch": false,
"isLandscape": false,
"isMobile": false
},
{
"id": "652a1171",
"image": "42c7b717e212fe83baa6bb0f35629284.png",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/liquid/components/ld-icon/ld-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class LdIcon {
const iconString = await fetchIcon(this.name)

div.innerHTML = iconString.replace('<svg', '<svg part="icon"')
this.element.shadowRoot.innerHTML = ''
this.element.shadowRoot.appendChild(div.firstChild)
}

Expand Down
12 changes: 12 additions & 0 deletions src/liquid/components/ld-icon/test/ld-icon.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ describe('ld-icon', () => {
expect(results).toMatchScreenshot()
})

it('replaces existing icon on icon name change', async () => {
const page = await getPageWithContent(`<ld-icon name="add"></ld-icon>`)
const ldIcon = await page.find('ld-icon')
expect(ldIcon).toHaveClasses(['hydrated'])

ldIcon.setProperty('name', 'matryoshka')
await page.waitForChanges()

const results = await page.compareScreenshot()
expect(results).toMatchScreenshot()
})

describe('sizes', () => {
it('sm', async () => {
const page = await getPageWithContent(
Expand Down

0 comments on commit 16605f0

Please sign in to comment.