Skip to content

Commit

Permalink
Allow string or number for the rotation prop (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
robmadole authored Mar 18, 2019
1 parent 1b3e339 commit f45dfcf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ var FontAwesomeIcon = {
default: false
},
rotation: {
type: Number,
type: [String, Number],
default: null,
validator: function validator(value) {
return [90, 180, 270].indexOf(value) > -1;
return [90, 180, 270].indexOf(parseInt(value, 10)) > -1;
}
},
size: {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@
default: false
},
rotation: {
type: Number,
type: [String, Number],
default: null,
validator: function validator(value) {
return [90, 180, 270].indexOf(value) > -1;
return [90, 180, 270].indexOf(parseInt(value, 10)) > -1;
}
},
size: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/FontAwesomeIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export default {
default: false
},
rotation: {
type: Number,
type: [String, Number],
default: null,
validator: (value) => [90, 180, 270].indexOf(value) > -1
validator: (value) => [90, 180, 270].indexOf(parseInt(value, 10)) > -1
},
size: {
type: String,
Expand Down
6 changes: 6 additions & 0 deletions src/components/__tests__/FontAwesomeIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ describe('using rotation', () => {

expect(vm.$el.classList.contains('fa-rotate-270')).toBeTruthy()
})

test('as a string', () => {
const vm = mountFromProps({ icon: faCoffee, rotation: '90' })

expect(vm.$el.classList.contains('fa-rotate-90')).toBeTruthy()
})
})

test('using size', () => {
Expand Down

0 comments on commit f45dfcf

Please sign in to comment.