main
Last change
on this file 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
|
Line | |
---|
1 | /**
|
---|
2 | * Returns the name of the prop given the JSXAttribute object.
|
---|
3 | */
|
---|
4 | export 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.