html2amp
html2amp copied to clipboard
Support `data-srcset`
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
I don't think it's a perfect solution but it might help someone else.
Here is the diff that solved my problem:
diff --git a/node_modules/html2amp/lib/utils.js b/node_modules/html2amp/lib/utils.js
index e17e685..a67a513 100644
--- a/node_modules/html2amp/lib/utils.js
+++ b/node_modules/html2amp/lib/utils.js
@@ -51,7 +51,7 @@ const normalizeSrc = (src, srcset) => {
const remoteImgCaches = new Map()
const srcNode = async (cwd, attributes) => {
const { src, alt = '', ...attrs } = attributes
- const url = normalizeUrl(normalizeSrc(src, attributes.srcset))
+ const url = normalizeUrl(normalizeSrc(src, attributes.srcset || attributes['data-srcset']))
let size = { width: null, height: null }
let result = null
if (url.startsWith('http')) {
This issue body was partially generated by patch-package.