get-pseudo-content
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

get-pseudo-content

npm dev dependencies browserstack


Returns a string as rendered from the content attribute of a pseudo element.

Installation

npm install --save-dev get-pseudo-content

Example

import getPseudoContent from "get-pseudo-content";

getPseudoContent(document.body, "::before");

Supports

  • string
  • attr()

Differences in raw output between browser

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

🐛 Edge: Failing to escape "

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/

Dependencies (0)

    Dev Dependencies (18)

    Package Sidebar

    Install

    npm i get-pseudo-content

    Weekly Downloads

    1

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    9.67 kB

    Total Files

    6

    Last publish

    Collaborators

    • lemnis