Skip to content

Commit 111cc4f

Browse files
authored
Merge pull request #128 from tomoyukikashiro/fix/type-attr-in-source
fix(picture): remove type attribute in source tag
2 parents 0d35827 + 49c295d commit 111cc4f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/utils.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ const srcNode = async (cwd, attributes) => {
6262
size = { width: result.width, height: result.height }
6363
fileStream.destroy()
6464
}
65-
// remove loading attribute
66-
// https://github.com/tomoyukikashiro/html2amp/issues/80
67-
let { loading, ..._attrs } = attrs
65+
// remove loading, type attributes (#80, #104)
66+
let { loading, type, ..._attrs } = attrs
6867
_attrs = { src: url, alt, width: size.width, height: size.height, layout: 'responsive', ..._attrs }
6968
const _attrsStr = Object.keys(_attrs).map(key => `${key}="${_attrs[key]}"`).join(' ')
7069
return `<amp-img ${_attrsStr}></amp-img>`

test/picture.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('picture', () => {
1717
const html = htmlFactory({ body: str })
1818
it('should be replaced with custom img tag', async () => {
1919
const $ = await picture(cheerio.load(html))
20-
const expectedTag = '<amp-img src="http://dummyimage.com/100x200/000/fff.png" alt="test" width="100" height="200" layout="responsive" type="image/png" srcset="http://dummyimage.com/100x200/000/fff.png 1x, http://dummyimage.com/200x400/000/fff.png 2x"><amp-img src="http://dummyimage.com/100x200/000/fff.jpg" alt="test" width="100" height="200" layout="responsive" type="image/jpg" srcset="http://dummyimage.com/100x200/000/fff.jpg 1x, http://dummyimage.com/200x400/000/fff.jpg 2x"></amp-img><amp-img src="http://dummyimage.com/200x400/000/fff.jpg" alt="test" width="200" height="400" layout="responsive" fallback=""></amp-img></amp-img>'
20+
const expectedTag = '<amp-img src="http://dummyimage.com/100x200/000/fff.png" alt="test" width="100" height="200" layout="responsive" srcset="http://dummyimage.com/100x200/000/fff.png 1x, http://dummyimage.com/200x400/000/fff.png 2x"><amp-img src="http://dummyimage.com/100x200/000/fff.jpg" alt="test" width="100" height="200" layout="responsive" srcset="http://dummyimage.com/100x200/000/fff.jpg 1x, http://dummyimage.com/200x400/000/fff.jpg 2x"></amp-img><amp-img src="http://dummyimage.com/200x400/000/fff.jpg" alt="test" width="200" height="400" layout="responsive" fallback=""></amp-img></amp-img>'
2121
const expected = htmlFactory({ body: expectedTag })
2222
assert($, expected)
2323
})

0 commit comments

Comments
 (0)