Skip to content

Commit 424a743

Browse files
committed
mapDomNodeToProps → mapNodeToProps
1 parent 0196bdf commit 424a743

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ const CoolGreeting = ({ userId, name }) => (
115115
)
116116
```
117117

118-
By using the `mapDomNodeToProps` prop, you can easily pass this data like so:
118+
By using the `mapNodeToProps` prop, you can easily pass this data like so:
119119

120120
```js
121121
import dataAttributes from 'data-attributes';
122122

123-
const mapDomNodeToProps = (node) => ({
123+
const mapNodeToProps = (node) => ({
124124
name: node.textContent,
125125
...dataAttributes(node)
126126
});
127127

128128
ReactDOM.render(
129-
<ElementPortal id="header" mapDomNodeToProps={mapDomNodeToProps} />,
129+
<ElementPortal id="header" mapNodeToProps={mapNodeToProps} />,
130130
document.getElementById('app')
131131
);
132132
```

src/ElementPortal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const ElementPortal = createReactClass({
1111
propTypes: {
1212
selector: PropTypes.string,
1313
component: PropTypes.func,
14-
mapDomNodeToProps: PropTypes.func,
14+
mapNodeToProps: PropTypes.func,
1515
resetStyle: PropTypes.bool
1616
},
1717

@@ -34,15 +34,15 @@ const ElementPortal = createReactClass({
3434
},
3535

3636
renderNode(node) {
37-
const mapDomNodeToProps = this.props.mapDomNodeToProps || noop;
37+
const mapNodeToProps = this.props.mapNodeToProps || noop;
3838

3939
if (this.props.resetStyle) {
4040
node.removeAttribute('class');
4141
node.removeAttribute('style');
4242
}
4343

4444
const children = this.props.component
45-
? React.createElement(this.props.component, mapDomNodeToProps(node))
45+
? React.createElement(this.props.component, mapNodeToProps(node))
4646
: React.Children.only(this.props.children);
4747

4848
ReactDOM.unstable_renderSubtreeIntoContainer(

src/withElementPortal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ function getDisplayName(Component) {
66
}
77

88
const withElementPortal = (Child) => {
9-
const Portal = ({ selector, resetStyle, mapDomNodeToProps, ...childProps }) => {
9+
const Portal = ({ selector, resetStyle, mapNodeToProps, ...childProps }) => {
1010
const ChildWrapper = (props) => <Child {...childProps} {...props} />;
1111
return <ElementPortal
1212
selector={selector}
1313
component={ChildWrapper}
14-
mapDomNodeToProps={mapDomNodeToProps}
14+
mapNodeToProps={mapNodeToProps}
1515
resetStyle={resetStyle}
1616
/>;
1717
};

test/ElementPortal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ test('map dom node to props', t => {
9595
<div id="${appId}">
9696
</div>
9797
`;
98-
const mapDomNodeToProps = (domNode) => ({
98+
const mapNodeToProps = (domNode) => ({
9999
name: domNode.textContent,
100100
isNew: !!domNode.getAttribute('data-new')
101101
});
102102
const Greeting = ({ name, isNew }) => (<div>Hello {isNew && 'and welcome '}{name}</div>);
103103
render(
104104
<div>
105-
<ElementPortal selector="li.greeting" component={Greeting} mapDomNodeToProps={mapDomNodeToProps} />
105+
<ElementPortal selector="li.greeting" component={Greeting} mapNodeToProps={mapNodeToProps} />
106106
</div>,
107107
document.getElementById(appId)
108108
);
@@ -238,7 +238,7 @@ test('map dom node to props when used as HOC', t => {
238238
<div id="${headerId}" data-new="true">Joe</div>
239239
<div id="${appId}">Mary</div>
240240
`;
241-
const mapDomNodeToProps = (domNode) => ({
241+
const mapNodeToProps = (domNode) => ({
242242
name: domNode.textContent,
243243
isNew: !!domNode.getAttribute('data-new')
244244
});
@@ -247,7 +247,7 @@ test('map dom node to props when used as HOC', t => {
247247

248248
render(
249249
<div>
250-
<GreetingWithPortal selector={`#${headerId}`} mapDomNodeToProps={mapDomNodeToProps} />
250+
<GreetingWithPortal selector={`#${headerId}`} mapNodeToProps={mapNodeToProps} />
251251
</div>,
252252
document.getElementById(appId)
253253
);

0 commit comments

Comments
 (0)