How to use the dom-expressions.SVGElements.has function in dom-expressions

To help you get started, we’ve selected a few dom-expressions 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 ryansolid / babel-plugin-jsx-dom-expressions / src / index.js View on Github external
function transformAttributes(path, jsx, results) {
    let elem = results.id;
    const spread = t.identifier("_$spread"),
      tagName = getTagName(jsx),
      isSVG = SVGElements.has(tagName);
    jsx.openingElement.attributes.forEach(attribute => {
      if (t.isJSXSpreadAttribute(attribute)) {
        registerImportMethod(path, "spread");
        results.exprs.push(
          t.expressionStatement(
            t.callExpression(spread, [
              elem,
              isDynamic(
                attribute.argument,
                lookupPathForExpr(path, attribute.argument)
              )
                ? t.arrowFunctionExpression([], attribute.argument)
                : attribute.argument,
              t.booleanLiteral(isSVG)
            ])
          )
github ryansolid / babel-plugin-jsx-dom-expressions / src / index.js View on Github external
function generateHTMLNode(path, jsx, opts, info = {}) {
    if (t.isJSXElement(jsx)) {
      let tagName = getTagName(jsx),
        wrapSVG = info.topLevel && tagName != "svg" && SVGElements.has(tagName),
        voidTag = VoidElements.indexOf(tagName) > -1;
      if (tagName !== tagName.toLowerCase())
        return generateComponent(path, jsx, opts);
      let results = {
        template: `<${tagName}`,
        decl: [],
        exprs: [],
        dynamics: [],
        isSVG: wrapSVG
      };
      if (wrapSVG) results.template = "<svg>" + results.template;
      if (!info.skipId) results.id = path.scope.generateUidIdentifier("el$");
      transformAttributes(path, jsx, results);
      if (
        contextToCustomElements &amp;&amp;
        (tagName === "slot" || tagName.indexOf("-") &gt; -1)
</svg>

dom-expressions

A Fine-Grained Runtime for Performant DOM Rendering

MIT
Latest version published 23 days ago

Package Health Score

75 / 100
Full package analysis

Similar packages