From e8979d9f05e47670200cd86c9f5e325b8ae503db Mon Sep 17 00:00:00 2001 From: Nathan Friedly Date: Wed, 5 May 2021 15:59:24 -0400 Subject: [PATCH] Update examples to not combine desity and width Hey, thanks for making this library! #6 updated the codebase to not allow density and width when parsing. (Although, amusingly, it does still allow it when stringifying - kind of the opposite of the robustness principle.) This updates the readme to match so that the examples are correct and parse-able. On a related note, would you be interested in another PR to make stringifying more strict? Also, what about a not-strict mode that does it's best and doesn't throw errors? (It would be handy for my use-case. For the moment I'm just wrapping this in a try/catch and using the original value if it throws.) --- readme.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 65a51a8..158abf5 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ How an image with `srcset` might look like: ```html The Breakfast Combo + srcset="banner-HD.jpg 2x, banner-phone.jpg 100w"> ``` Then have some fun with it: @@ -41,15 +41,14 @@ console.log(parsed); */ parsed.push({ - url: 'banner-phone-HD.jpg', - width: 100, - density: 2 + url: 'banner-super-HD.jpg', + density: 3 }); const stringified = srcset.stringify(parsed); console.log(stringified); /* -banner-HD.jpg 2x, banner-phone.jpg 100w, banner-phone-HD.jpg 100w 2x +banner-HD.jpg 2x, banner-phone.jpg 100w, banner-super-HD.jpg 3x */ ```