How to use the isJSXElement function from @babel/types

Find comprehensive JavaScript @babel/types.isJSXElement code examples handpicked from public code repositorys.

72
73
74
75
76
77
78
79
80
81
  }
}
// 配合安震,解析c-slider;
exports.parseTagForSlider = function(path, type, options) {
  let node = path.node;
  if ((['wx', 'qq', 'baidu', 'alipay', 'tt'].includes(type)) && t.isJSXElement(node)) {
    let currentTag = node.openingElement.name.name;
    let targetTag = tagMap.wxTagMap[currentTag];
    if (targetTag && currentTag !== targetTag) {
      node.openingElement.name.name = targetTag;
fork icon700
star icon0
watch icon239

+ 13 other calls in file

184
185
186
187
188
189
190
191
192
193
  [adapter.for]: t.jsxExpressionContainer(forNode),
  [adapter.forItem]: t.stringLiteral(forItem.name),
  [adapter.forIndex]: t.stringLiteral(renamedIndex.name),
};

if (adapter.needTransformKey && t.isJSXElement(returnElPath.node)) {
  const attributes = returnElPath.node.openingElement.attributes;
  const keyIndex = findIndex(attributes, attr => t.isJSXIdentifier(attr.name, { name: 'key' }));
  if (keyIndex > -1) {
    listAttr.key = attributes[keyIndex].value;
fork icon663
star icon11
watch icon1

+ 13 other calls in file

158
159
160
161
162
163
164
165
166
167
// { foo }
case 'Identifier': {
  const id = node.expression.name.trim();
  if (
    templateVariables[id] &&
    t.isJSXElement(templateVariables[id].value)
  ) {
    // => <block a:if="xxx">
    path.replaceWith(templateVariables[id].value);
  }
fork icon663
star icon0
watch icon1

+ 3 other calls in file

44
45
46
47
48
49
50
51
52
53
  }
},
generate(ret, parsed, options) {
  if (parsed[TEMPLATE_AST]) {
    const lastTemplateDefineIdx = findIndex(parsed[TEMPLATE_AST].children,
      (node) => t.isJSXElement(node) && node.openingElement.name.name !== 'template');
    const templateDefineNodes = parsed[TEMPLATE_AST].children.splice(0, lastTemplateDefineIdx);
    ret.template = [
      ...templateDefineNodes.map(node => genExpression(node, {
        comments: false,
fork icon663
star icon0
watch icon1

+ 5 other calls in file

2
3
4
5
6
7
8
9
10
11

class ElementUtil {
  constructor(path) {
    this.path = path;
    this.node = path && path.node;
    this.isValid = t.isJSXElement(this.node);
  }

  /**
   * 返回标签名
fork icon13
star icon89
watch icon4

+ 21 other calls in file

55
56
57
58
59
60
61
62
63

  return storySource.substring(returnBody.start, returnBody.end);
}

function isImplicitReturn(bodyNode) {
  return t.isJSXElement(bodyNode) || t.isJSXFragment(bodyNode);
}

module.exports = { extractMetadata, extractDocgenInfo, validateDsmInfo };
fork icon3
star icon13
watch icon21

+ 7 other calls in file

92
93
94
95
96
97
98
99
100
101
ThisExpression (thisPath) {
    const parentNode = thisPath.parentPath.parentPath.parent;
    const isValid = t.isExpressionStatement(parentNode) || 
        t.isVariableDeclaration(parentNode) ||
        t.isBlockStatement(parentNode) || 
        t.isJSXElement(parentNode) || 
        t.isCallExpression(parentNode) || 
        (t.isJSXAttribute(parentNode) && !parentNode.name.name.startsWith('on'));

    if (isValid) {
fork icon65
star icon1
watch icon1

125
126
127
128
129
130
131
132
133
134
135
136


exports.isGlobalEl = isGlobalEl;


var isStyledJsx = function isStyledJsx(_ref2) {
  var el = _ref2.node;
  return t.isJSXElement(el) && el.openingElement.name.name === 'style' && el.openingElement.attributes.some(function (attr) {
    return attr.name.name === _constants.STYLE_ATTRIBUTE;
  });
};

fork icon0
star icon1
watch icon0

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)