react-paginate
Advanced tools
Comparing version 6.3.0 to 6.3.1
@@ -410,10 +410,22 @@ import React from 'react'; | ||
marginPagesDisplayed={2} | ||
ariaLabelBuilder={(page, selected) => selected ? 'Current page' : 'Goto page ' + page } /> | ||
ariaLabelBuilder={(page, selected) => | ||
selected ? 'Current page' : 'Goto page ' + page | ||
} | ||
/> | ||
); | ||
expect(ReactDOM.findDOMNode(linkedPagination).querySelector('li:nth-last-child(2) a') | ||
.getAttribute('aria-label')).toBe('Goto page 3'); | ||
expect(ReactDOM.findDOMNode(linkedPagination).querySelector('li:nth-child(2) a') | ||
.getAttribute('aria-label')).toBe('Goto page 1'); | ||
expect(ReactDOM.findDOMNode(linkedPagination).querySelector('.selected a') | ||
.getAttribute('aria-label')).toBe('Current page'); | ||
expect( | ||
ReactDOM.findDOMNode(linkedPagination) | ||
.querySelector('li:nth-last-child(2) a') | ||
.getAttribute('aria-label') | ||
).toBe('Goto page 3'); | ||
expect( | ||
ReactDOM.findDOMNode(linkedPagination) | ||
.querySelector('li:nth-child(2) a') | ||
.getAttribute('aria-label') | ||
).toBe('Goto page 1'); | ||
expect( | ||
ReactDOM.findDOMNode(linkedPagination) | ||
.querySelector('.selected a') | ||
.getAttribute('aria-label') | ||
).toBe('Current page'); | ||
}); | ||
@@ -428,11 +440,23 @@ | ||
marginPagesDisplayed={2} | ||
ariaLabelBuilder={(page, selected) => selected ? 'Current page' : 'Goto page ' + page } | ||
extraAriaContext="foobar" /> | ||
ariaLabelBuilder={(page, selected) => | ||
selected ? 'Current page' : 'Goto page ' + page | ||
} | ||
extraAriaContext="foobar" | ||
/> | ||
); | ||
expect(ReactDOM.findDOMNode(linkedPagination).querySelector('li:nth-last-child(2) a') | ||
.getAttribute('aria-label')).toBe('Goto page 3 foobar'); | ||
expect(ReactDOM.findDOMNode(linkedPagination).querySelector('li:nth-child(2) a') | ||
.getAttribute('aria-label')).toBe('Goto page 1 foobar'); | ||
expect(ReactDOM.findDOMNode(linkedPagination).querySelector('.selected a') | ||
.getAttribute('aria-label')).toBe('Current page'); | ||
expect( | ||
ReactDOM.findDOMNode(linkedPagination) | ||
.querySelector('li:nth-last-child(2) a') | ||
.getAttribute('aria-label') | ||
).toBe('Goto page 3 foobar'); | ||
expect( | ||
ReactDOM.findDOMNode(linkedPagination) | ||
.querySelector('li:nth-child(2) a') | ||
.getAttribute('aria-label') | ||
).toBe('Goto page 1 foobar'); | ||
expect( | ||
ReactDOM.findDOMNode(linkedPagination) | ||
.querySelector('.selected a') | ||
.getAttribute('aria-label') | ||
).toBe('Current page'); | ||
}); | ||
@@ -768,2 +792,18 @@ }); | ||
}); | ||
it('should update forcePage and hence selected page when forcePage value is changed', () => { | ||
const node = document.createElement('div'); | ||
const pagination1 = ReactDOM.render( | ||
<PaginationBoxView forcePage={2} />, | ||
node | ||
); | ||
const pagination2 = ReactDOM.render( | ||
<PaginationBoxView forcePage={3} />, | ||
node | ||
); | ||
expect( | ||
ReactDOM.findDOMNode(pagination2).querySelector('.selected a') | ||
.textContent | ||
).toBe('4'); | ||
}); | ||
}); | ||
@@ -770,0 +810,0 @@ |
@@ -207,6 +207,6 @@ 'use strict'; | ||
}, { | ||
key: 'UNSAFE_componentWillReceiveProps', | ||
value: function UNSAFE_componentWillReceiveProps(nextProps) { | ||
if (typeof nextProps.forcePage !== 'undefined' && this.props.forcePage !== nextProps.forcePage) { | ||
this.setState({ selected: nextProps.forcePage }); | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps) { | ||
if (typeof this.props.forcePage !== 'undefined' && this.props.forcePage !== prevProps.forcePage) { | ||
this.setState({ selected: this.props.forcePage }); | ||
} | ||
@@ -213,0 +213,0 @@ } |
@@ -0,1 +1,5 @@ | ||
## >= 6.3.1 | ||
- Handle 'forcePage' value if set from outside (see: https://github.com/AdeleD/react-paginate/pull/272). | ||
## >= 6.3.0 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "react-paginate", | ||
"version": "6.3.0", | ||
"version": "6.3.1", | ||
"description": "A ReactJS component that creates a pagination.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -86,8 +86,8 @@ 'use strict'; | ||
UNSAFE_componentWillReceiveProps(nextProps) { | ||
componentDidUpdate(prevProps) { | ||
if ( | ||
typeof nextProps.forcePage !== 'undefined' && | ||
this.props.forcePage !== nextProps.forcePage | ||
typeof this.props.forcePage !== 'undefined' && | ||
this.props.forcePage !== prevProps.forcePage | ||
) { | ||
this.setState({ selected: nextProps.forcePage }); | ||
this.setState({ selected: this.props.forcePage }); | ||
} | ||
@@ -94,0 +94,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
302550
2155