source: imaps-frontend/node_modules/jsx-ast-utils/src/propName.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 404 bytes
RevLine 
[d565449]1/**
2 * Returns the name of the prop given the JSXAttribute object.
3 */
4export default function propName(prop = {}) {
5 if (!prop.type || prop.type !== 'JSXAttribute') {
6 throw new Error('The prop must be a JSXAttribute collected by the AST parser.');
7 }
8
9 if (prop.name.type === 'JSXNamespacedName') {
10 return `${prop.name.namespace.name}:${prop.name.name.name}`;
11 }
12
13 return prop.name.name;
14}
Note: See TracBrowser for help on using the repository browser.