Skip to content

Commit 09d2a9c

Browse files
committed
Phenome: use display name in react children
Fixes #2459
1 parent ddae10f commit 09d2a9c

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

src/phenome/components/fab.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export default {
4444
const child = defaultSlots[i];
4545
let isRoot;
4646
if (process.env.COMPILER === 'react') {
47-
const tag = child.type && child.type.name;
48-
if (tag === 'F7FabButtons') isRoot = true;
47+
const tag = child.type && (child.type.displayName || child.type.name);
48+
if (tag === 'F7FabButtons' || tag === 'f7-fab-buttons') isRoot = true;
4949
}
5050
if (process.env.COMPILER === 'vue') {
5151
if (child.tag && child.tag.indexOf('fab-buttons') >= 0) isRoot = true;

src/phenome/components/list-item-content.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ export default {
123123
flattenSlots.forEach((child) => {
124124
if (typeof child === 'undefined') return;
125125
if (process.env.COMPILER === 'react') {
126-
const tag = child.type && child.type.name;
127-
if (tag === 'F7Input') {
126+
const tag = child.type && (child.type.displayName || child.type.name);
127+
if (tag === 'F7Input' || tag === 'f7-input') {
128128
hasInput = true;
129129
if (child.props && child.props.info) hasInputInfo = true;
130130
if (child.props && child.props.errorMessage && child.props.errorMessageForce) hasInputErrorMessage = true;
131131
}
132-
if (tag === 'F7Label') {
132+
if (tag === 'F7Label' || tag === 'f7-label') {
133133
if (child.props && child.props.inline) hasInlineLabel = true;
134134
}
135135
}

src/phenome/components/list.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default {
5757
if (typeof child === 'undefined') return;
5858
let tag;
5959
if (process.env.COMPILER === 'react') {
60-
tag = child.type && child.type.name;
60+
tag = child.type && (child.type.displayName || child.type.name);
6161
if (!tag && typeof child.type === 'string') {
6262
tag = child.type;
6363
}
@@ -67,13 +67,15 @@ export default {
6767
}
6868

6969
if (
70-
(!tag && process.env.COMPILER === 'react') ||
71-
(tag && !(
72-
tag === 'li' ||
73-
tag === 'F7ListItem' ||
74-
tag === 'F7ListButton' ||
75-
tag.indexOf('list-item') >= 0 ||
76-
tag.indexOf('list-button') >= 0
70+
(!tag && process.env.COMPILER === 'react')
71+
|| (tag && !(
72+
tag === 'li'
73+
|| tag === 'F7ListItem'
74+
|| tag === 'F7ListButton'
75+
|| tag.indexOf('list-item') >= 0
76+
|| tag.indexOf('list-button') >= 0
77+
|| tag.indexOf('f7-list-item') >= 0
78+
|| tag.indexOf('f7-list-button') >= 0
7779
))
7880
) {
7981
if (wasUlChild) rootChildrenAfterList.push(child);

src/phenome/components/messagebar.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ export default {
8888
if (typeof child === 'undefined') return;
8989
let tag;
9090
tag = child.tag; // phenome-vue-line
91-
tag = child.type && child.type.name; // phenome-react-line
91+
tag = child.type && (child.type.displayName || child.type.name); // phenome-react-line
9292

93-
if (tag && (tag.indexOf('messagebar-attachments') >= 0 || tag === 'F7MessagebarAttachments')) {
93+
if (tag && (tag.indexOf('messagebar-attachments') >= 0 || tag === 'F7MessagebarAttachments' || tag === 'f7-messagebar-attachments')) {
9494
messagebarAttachmentsEl = child;
95-
} else if (tag && (tag.indexOf('messagebar-sheet') >= 0 || tag === 'F7MessagebarSheet')) {
95+
} else if (tag && (tag.indexOf('messagebar-sheet') >= 0 || tag === 'F7MessagebarSheet' || tag === 'f7-messagebar-sheet')) {
9696
messagebarSheetEl = child;
9797
} else {
9898
innerEndEls.push(child);
@@ -125,11 +125,11 @@ export default {
125125
/>
126126
{slotsAfterArea}
127127
</div>
128-
{((sendLink && sendLink.length > 0) || slotsSendLink) &&
128+
{((sendLink && sendLink.length > 0) || slotsSendLink) && (
129129
<F7Link onClick={self.onClickBound}>
130130
{slotsSendLink || sendLink}
131131
</F7Link>
132-
}
132+
)}
133133
{slotsInnerEnd}
134134
{innerEndEls}
135135
</div>

src/phenome/components/page.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default {
8484
// phenome-vue-next-line
8585
fixedTags = ('navbar toolbar tabbar subnavbar searchbar messagebar fab list-index').split(' ');
8686
// phenome-react-next-line
87-
fixedTags = ('Navbar Toolbar Tabbar Subnavbar Searchbar Messagebar Fab ListIndex').split(' ').map(tagName => `F7${tagName}`);
87+
fixedTags = ('navbar toolbar tabbar subnavbar searchbar messagebar fab list-index').split(' ').map(tagName => `f7-${tagName}`);
8888

8989
let hasSubnavbar;
9090
let hasMessages;
@@ -96,13 +96,13 @@ export default {
9696
if (typeof child === 'undefined') return;
9797
let isFixedTag = false;
9898
if (process.env.COMPILER === 'react') {
99-
const tag = child.type && child.type.name;
99+
const tag = child.type && (child.type.displayName || child.type.name);
100100
if (!tag) {
101101
if (needsPageContent) staticList.push(child);
102102
return;
103103
}
104-
if (tag === 'F7Subnavbar') hasSubnavbar = true;
105-
if (typeof hasMessages === 'undefined' && tag === 'F7Messages') hasMessages = true;
104+
if (tag === 'F7Subnavbar' || tag === 'f7-subnavbar') hasSubnavbar = true;
105+
if (typeof hasMessages === 'undefined' && (tag === 'F7Messages' || tag === 'f7-messages')) hasMessages = true;
106106
if (fixedTags.indexOf(tag) >= 0) {
107107
isFixedTag = true;
108108
}

src/phenome/components/sheet.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
// phenome-vue-next-line
2525
fixedTags = ('navbar toolbar tabbar subnavbar searchbar messagebar fab list-index').split(' ');
2626
// phenome-react-next-line
27-
fixedTags = ('Navbar Toolbar Tabbar Subnavbar Searchbar Messagebar Fab ListIndex').split(' ').map(tagName => `F7${tagName}`);
27+
fixedTags = ('navbar toolbar tabbar subnavbar searchbar messagebar fab list-index').split(' ').map(tagName => `f7-${tagName}`);
2828

2929
const slotsDefault = self.slots.default;
3030

@@ -33,7 +33,7 @@ export default {
3333
if (typeof child === 'undefined') return;
3434
let isFixedTag = false;
3535
if (process.env.COMPILER === 'react') {
36-
const tag = child.type && child.type.name;
36+
const tag = child.type && (child.type.displayName || child.type.name);
3737
if (!tag) {
3838
return;
3939
}

0 commit comments

Comments
 (0)