mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 12:15:37 +08:00
Add support for number as colors
Summary: Closes https://github.com/facebook/react-native/pull/5805 Reviewed By: svcscm Differential Revision: D2911330 Pulled By: javache fb-gh-sync-id: b07c00a9271a161e3c88755434f6ffa34f4d519d
This commit is contained in:
committed by
facebook-github-bot-7
parent
90403154a2
commit
1c112762e3
@@ -12,12 +12,19 @@
|
||||
/* eslint no-bitwise: 0 */
|
||||
'use strict';
|
||||
|
||||
function normalizeColor(color: string): ?number {
|
||||
function normalizeColor(color: string | number): ?number {
|
||||
var match;
|
||||
|
||||
if (typeof color === 'number') {
|
||||
if (color >>> 0 === color && color >= 0 && color <= 0xffffffff) {
|
||||
return color;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ordered based on occurrences on Facebook codebase
|
||||
if ((match = matchers.hex6.exec(color))) {
|
||||
return (parseInt(match[1], 16) << 8 | 0x000000ff) >>> 0;
|
||||
return parseInt(match[1] + 'ff', 16) >>> 0;
|
||||
}
|
||||
|
||||
if (names.hasOwnProperty(color)) {
|
||||
|
||||
Reference in New Issue
Block a user