11/**
2- * Copyright 2014-2015, Facebook, Inc.
3- * All rights reserved.
2+ * Copyright (c) 2014-present, Facebook, Inc.
43 *
5- * This source code is licensed under the BSD-style license found in the
6- * LICENSE file in the root directory of this source tree. An additional grant
7- * of patent rights can be found in the PATENTS file in the same directory.
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @providesModule warning
88 */
99
1010'use strict' ;
@@ -21,40 +21,42 @@ var __DEV__ = process.env.NODE_ENV !== 'production';
2121var warning = function ( ) { } ;
2222
2323if ( __DEV__ ) {
24- warning = function ( condition , format , args ) {
24+ function printWarning ( format , args ) {
2525 var len = arguments . length ;
2626 args = new Array ( len > 2 ? len - 2 : 0 ) ;
2727 for ( var key = 2 ; key < len ; key ++ ) {
2828 args [ key - 2 ] = arguments [ key ] ;
2929 }
30- if ( format === undefined ) {
31- throw new Error (
32- '`warning(condition, format, ...args)` requires a warning ' +
33- 'message argument'
34- ) ;
30+ var argIndex = 0 ;
31+ var message = 'Warning: ' +
32+ format . replace ( / % s / g, function ( ) {
33+ return args [ argIndex ++ ] ;
34+ } ) ;
35+ if ( typeof console !== 'undefined' ) {
36+ console . error ( message ) ;
3537 }
38+ try {
39+ // --- Welcome to debugging React ---
40+ // This error was thrown as a convenience so that you can use this stack
41+ // to find the callsite that caused this warning to fire.
42+ throw new Error ( message ) ;
43+ } catch ( x ) { }
44+ }
3645
37- if ( format . length < 10 || ( / ^ [ s \W ] * $ / ) . test ( format ) ) {
46+ warning = function ( condition , format , args ) {
47+ var len = arguments . length ;
48+ args = new Array ( len > 2 ? len - 2 : 0 ) ;
49+ for ( var key = 2 ; key < len ; key ++ ) {
50+ args [ key - 2 ] = arguments [ key ] ;
51+ }
52+ if ( format === undefined ) {
3853 throw new Error (
39- 'The warning format should be able to uniquely identify this ' +
40- 'warning. Please, use a more descriptive format than: ' + format
54+ '` warning(condition, format, ...args)` requires a warning ' +
55+ 'message argument'
4156 ) ;
4257 }
43-
4458 if ( ! condition ) {
45- var argIndex = 0 ;
46- var message = 'Warning: ' +
47- format . replace ( / % s / g, function ( ) {
48- return args [ argIndex ++ ] ;
49- } ) ;
50- if ( typeof console !== 'undefined' ) {
51- console . error ( message ) ;
52- }
53- try {
54- // This error was thrown as a convenience so that you can use this stack
55- // to find the callsite that caused this warning to fire.
56- throw new Error ( message ) ;
57- } catch ( x ) { }
59+ printWarning . apply ( null , [ format ] . concat ( args ) ) ;
5860 }
5961 } ;
6062}
0 commit comments