Created
August 20, 2024 16:05
-
-
Save robmiller/3b380745d1ad0c2104bc77641ac2bf5c to your computer and use it in GitHub Desktop.
Extremely simple polyfill for hanging-punctuation in Chrome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
I only really use hanging-punctuation: first and only expect it to | |
work in blockquotes, which makes the usage extremely simple. And yet | |
for some reason I've never done a simple polyfill. Now I have. | |
*/ | |
(function() { | |
if ( !CSS.supports("hanging-punctuation", "first") ) { | |
document.querySelectorAll("p").forEach(e => { if ( e.innerText.trim()[0] == "“" ) { e.style.textIndent = "-0.725ch"; } }); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment