How to use the css-tree.List.createItem function in css-tree

To help you get started, we’ve selected a few css-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github css / csso / lib / compress.js View on Github external
if (ast.type === 'StyleSheet') {
        input = ast.children;
        ast.children = output;
    } else {
        input = wrapBlock(ast);
    }

    do {
        chunk = readChunk(input, Boolean(specialComments));
        compressChunk(chunk.stylesheet, firstAtrulesAllowed, chunkNum++, compressOptions);
        chunkChildren = chunk.stylesheet.children;

        if (chunk.comment) {
            // add \n before comment if there is another content in output
            if (!output.isEmpty()) {
                output.insert(List.createItem({
                    type: 'Raw',
                    value: '\n'
                }));
            }

            output.insert(List.createItem(chunk.comment));

            // add \n after comment if chunk is not empty
            if (!chunkChildren.isEmpty()) {
                output.insert(List.createItem({
                    type: 'Raw',
                    value: '\n'
                }));
            }
        }
github css / csso / lib / compress.js View on Github external
do {
        chunk = readChunk(input, Boolean(specialComments));
        compressChunk(chunk.stylesheet, firstAtrulesAllowed, chunkNum++, compressOptions);
        chunkChildren = chunk.stylesheet.children;

        if (chunk.comment) {
            // add \n before comment if there is another content in output
            if (!output.isEmpty()) {
                output.insert(List.createItem({
                    type: 'Raw',
                    value: '\n'
                }));
            }

            output.insert(List.createItem(chunk.comment));

            // add \n after comment if chunk is not empty
            if (!chunkChildren.isEmpty()) {
                output.insert(List.createItem({
                    type: 'Raw',
                    value: '\n'
                }));
            }
        }

        if (firstAtrulesAllowed && !chunkChildren.isEmpty()) {
            var lastRule = chunkChildren.last();

            if (lastRule.type !== 'Atrule' ||
               (lastRule.name !== 'import' && lastRule.name !== 'charset')) {
                firstAtrulesAllowed = false;
github triplecanopy / b-ber / packages / b-ber-reader / src / helpers / XMLAdaptor.js View on Github external
enter: (node, item, list) => {
              let value
              let nodeText

              const scopedClassName = List.createItem({
                name: hashedClassName,
                type: 'ClassSelector',
              })
              const whiteSpace = List.createItem({
                type: 'WhiteSpace',
                value: ' ',
              })

              // these need to be synced with the
              // HTML structure in Layout.jsx
              if (
                list &&
                node.type === 'TypeSelector' &&
                node.name === 'html'
              ) {
                node.name = hashedClassName // eslint-disable-line no-param-reassign
github triplecanopy / b-ber / packages / b-ber-reader / src / helpers / XMLAdaptor.js View on Github external
enter: (node, item, list) => {
              let value
              let nodeText

              const scopedClassName = List.createItem({
                name: hashedClassName,
                type: 'ClassSelector',
              })
              const whiteSpace = List.createItem({
                type: 'WhiteSpace',
                value: ' ',
              })

              // these need to be synced with the
              // HTML structure in Layout.jsx
              if (
                list &&
                node.type === 'TypeSelector' &&
                node.name === 'html'
              ) {
                node.name = hashedClassName // eslint-disable-line no-param-reassign
                node.type = 'ClassSelector' // eslint-disable-line no-param-reassign
              }

              if (