Returns a string as rendered from the content attribute of a pseudo element.
npm install --save-dev get-pseudo-contentimport getPseudoContent from "get-pseudo-content";
getPseudoContent(document.body, "::before");- string
attr()
| Blink | Webkit | Gecko | Trident | |
|---|---|---|---|---|
| encloses single strings | yes | no | yes | yes |
| combines multiple strings | yes | yes | no | no |
returns line breaks as \a |
yes | yes | yes | no |
| returns line breaks as new lines even when rendered on a single line |
no | no | no | yes |
renders attr() as actual string |
yes | yes | no | no |
escapes " |
yes | yes | yes | no |
When a double quote is preceded with a space, this library is unable return the correct value. Related bug report: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20351981/