Function parseMediaQueryList

  • creates an AST from a media-query-list string; parses comma-separated media queries correctly

    Important:

    • an invalid media-query child does not make the media-query-list invalid
    • each invalid media query child is replaced with undefined
    • can return a ParserError (e.g. when there is a CSS syntax error, like an invalid string)

    Parameters

    • str: string

    Returns QueryListNode | ParserError

    Example

    console.log(parseMediaQueryList(`print, #invalid, (min-width: 1000px)`));
    // {
    // _t: "query-list",
    // nodes: [
    // { _t: "query", type: "print", start: 0, end: 4 },
    // undefined,
    // {
    // _t: "query",
    // condition: {
    // _t: "condition",
    // op: "and",
    // nodes: [
    // {
    // _t: "in-parens",
    // node: {
    // _t: "feature",
    // context: "value",
    // feature: "min-width",
    // value: { _t: "dimension", value: 1000, unit: "px", start: 29, end: 34 },
    // start: 18,
    // end: 34,
    // },
    // },
    // ],
    // start: 17,
    // end: 35,
    // },
    // start: 0,
    // end: 35,
    // },
    // ],
    // }

Generated using TypeDoc