Compare commits
1155 Commits
asserts-st
...
v15.6.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7efd2e58d0 | ||
|
|
a3d0dbcaa9 | ||
|
|
0c102ac204 | ||
|
|
9ba0c8097f | ||
|
|
5b89c1bb2d | ||
|
|
83d0dc4989 | ||
|
|
230d0ec277 | ||
|
|
240874d0f4 | ||
|
|
4013e234c5 | ||
|
|
d494d2d332 | ||
|
|
80255d10bf | ||
|
|
782e433788 | ||
|
|
ae94ea76f9 | ||
|
|
2ddff2e339 | ||
|
|
123c7cddfd | ||
|
|
cd262c7e04 | ||
|
|
d5c2bdb92f | ||
|
|
0deda1f5e7 | ||
|
|
461a5a2529 | ||
|
|
3377abf46a | ||
|
|
24e698a93b | ||
|
|
4f17e8a03a | ||
|
|
d9d8cf658a | ||
|
|
820310fcf4 | ||
|
|
4d44dfb2a8 | ||
|
|
00917c80e8 | ||
|
|
c1fe2549c8 | ||
|
|
a5e69ca8ea | ||
|
|
4db80b960c | ||
|
|
a3ff734cbc | ||
|
|
4ac06723e6 | ||
|
|
16d7773b3c | ||
|
|
0652bb4633 | ||
|
|
8af5d233ef | ||
|
|
501cb45b51 | ||
|
|
156dd49a44 | ||
|
|
129307f8a4 | ||
|
|
78eda5525b | ||
|
|
1de60827e3 | ||
|
|
47334a18d2 | ||
|
|
7c2ce278c5 | ||
|
|
b0a67c9fa9 | ||
|
|
d095bc8391 | ||
|
|
9ac30f5477 | ||
|
|
f127ba6b21 | ||
|
|
207f3ef457 | ||
|
|
66b42830e0 | ||
|
|
c62675cda4 | ||
|
|
f931ad7d25 | ||
|
|
152d94d898 | ||
|
|
debf4f85e6 | ||
|
|
6bef36d9fa | ||
|
|
a5e0067358 | ||
|
|
b0777a695a | ||
|
|
eec984d80d | ||
|
|
b77fd87b52 | ||
|
|
4def415fb5 | ||
|
|
81d1519ebb | ||
|
|
9d60d38abe | ||
|
|
f60f5fe77b | ||
|
|
88815d6eeb | ||
|
|
1a663a4a3f | ||
|
|
db6c10c1e3 | ||
|
|
018189a3e7 | ||
|
|
74861dd9b0 | ||
|
|
80252af027 | ||
|
|
9a2ddbddc9 | ||
|
|
0bee1300bf | ||
|
|
7a3472ea53 | ||
|
|
dd988162a1 | ||
|
|
a8e2a33f1e | ||
|
|
18eff07423 | ||
|
|
1f943df61d | ||
|
|
60332131d9 | ||
|
|
c51f8bc995 | ||
|
|
3b7a6c8b56 | ||
|
|
aef13f093d | ||
|
|
5458982197 | ||
|
|
3300ecb48a | ||
|
|
bf4af51c99 | ||
|
|
4700f30d19 | ||
|
|
e9c77935b4 | ||
|
|
2413107b1d | ||
|
|
f66c60c636 | ||
|
|
11ef9da924 | ||
|
|
edd83dd8fc | ||
|
|
292565fbc3 | ||
|
|
34ab372824 | ||
|
|
cf41c522a9 | ||
|
|
fc33c50020 | ||
|
|
4ad20dbf00 | ||
|
|
e85ec2f735 | ||
|
|
5b77e75b6a | ||
|
|
efd2808071 | ||
|
|
4a91038cef | ||
|
|
7723dc4a39 | ||
|
|
11d2471640 | ||
|
|
a7524ab0dd | ||
|
|
dd8ac14522 | ||
|
|
4b577eb731 | ||
|
|
3f8c23e628 | ||
|
|
ac59a271cb | ||
|
|
1e68095b91 | ||
|
|
17d5b63e36 | ||
|
|
0103dd1d38 | ||
|
|
28c914decf | ||
|
|
1ad0a3309f | ||
|
|
a5d07f0cac | ||
|
|
8706e4390f | ||
|
|
8b71e9fced | ||
|
|
a6102842ac | ||
|
|
97542e7a99 | ||
|
|
7b7a3e9860 | ||
|
|
7bdf33b2c5 | ||
|
|
dda27a3515 | ||
|
|
bed4e33259 | ||
|
|
f56ba1467f | ||
|
|
6a095209fe | ||
|
|
4fd77b14b9 | ||
|
|
dea8f6a653 | ||
|
|
3e7c17217e | ||
|
|
beb370c102 | ||
|
|
61e8ee71b6 | ||
|
|
088d593b0b | ||
|
|
41e135e270 | ||
|
|
871bd7e0c0 | ||
|
|
ce3ecfb1df | ||
|
|
3c898931ed | ||
|
|
ae89a74091 | ||
|
|
fc542d7f78 | ||
|
|
ddae1cd39f | ||
|
|
874a8ecc58 | ||
|
|
2421bc6e73 | ||
|
|
fd752538a5 | ||
|
|
98ae5aaf96 | ||
|
|
105b95bf17 | ||
|
|
414deb16ce | ||
|
|
1ded80debd | ||
|
|
4974989003 | ||
|
|
e46dc02e7d | ||
|
|
597b14579e | ||
|
|
b51cd8ff12 | ||
|
|
d5c3afda2f | ||
|
|
f78299469f | ||
|
|
f1c449ff1d | ||
|
|
f593e98201 | ||
|
|
3d019b3cc7 | ||
|
|
242565f232 | ||
|
|
ad3a6cb067 | ||
|
|
518de2edb5 | ||
|
|
a08035b003 | ||
|
|
b02bbfebe7 | ||
|
|
63795005d3 | ||
|
|
e5b3554edc | ||
|
|
fe031caf69 | ||
|
|
78fc25f251 | ||
|
|
f93324496f | ||
|
|
98fde611ef | ||
|
|
b34a312e6c | ||
|
|
6086a22482 | ||
|
|
b43f830101 | ||
|
|
b48b2594fa | ||
|
|
3f62cd557f | ||
|
|
16a62c248b | ||
|
|
d97317e806 | ||
|
|
413c7b548a | ||
|
|
1d7971a85a | ||
|
|
68347c9985 | ||
|
|
cde14be002 | ||
|
|
5c415d1e64 | ||
|
|
5c25cda519 | ||
|
|
28bef90a86 | ||
|
|
0b48a3e8e1 | ||
|
|
0d74dfb317 | ||
|
|
2bbe02456b | ||
|
|
4f7136e1d7 | ||
|
|
0001036d35 | ||
|
|
850231c6da | ||
|
|
07f57661f0 | ||
|
|
c9864556e9 | ||
|
|
d2be47b8c4 | ||
|
|
e29871e6be | ||
|
|
115452f87e | ||
|
|
e084900e5c | ||
|
|
d34eba0b33 | ||
|
|
aba76bf4ff | ||
|
|
ee1a400a8f | ||
|
|
6052d7b455 | ||
|
|
ea5f8cdb03 | ||
|
|
a32974a2b0 | ||
|
|
aa1570cf35 | ||
|
|
295b733ab2 | ||
|
|
08234e7b32 | ||
|
|
eaadfb856d | ||
|
|
961fe7310f | ||
|
|
5bb1ad113e | ||
|
|
e38445d04a | ||
|
|
be4f0c2f41 | ||
|
|
a30937f6f6 | ||
|
|
8b48a394ea | ||
|
|
4a230dc75e | ||
|
|
fd3830453f | ||
|
|
ac1a4665e2 | ||
|
|
928609d128 | ||
|
|
451a3aa2f7 | ||
|
|
009c9f7201 | ||
|
|
ad1d3526f5 | ||
|
|
1926f9ab06 | ||
|
|
a6b51ed8fb | ||
|
|
25177ec4ea | ||
|
|
2a5aaccd7a | ||
|
|
b2b612ec5d | ||
|
|
6ef3fde642 | ||
|
|
8597fd4e12 | ||
|
|
85b3cdec82 | ||
|
|
1001454683 | ||
|
|
e6df2eccfe | ||
|
|
3e44b5dc25 | ||
|
|
f8ade2b30c | ||
|
|
53a0064533 | ||
|
|
6afb4826f2 | ||
|
|
3a8effb4fb | ||
|
|
8991f26887 | ||
|
|
7482e2a0e3 | ||
|
|
8f93e269d8 | ||
|
|
2a44c5c726 | ||
|
|
20a9c31f3d | ||
|
|
006ebb6421 | ||
|
|
7323d4cece | ||
|
|
150c2e57f7 | ||
|
|
a63ecad10e | ||
|
|
d333bff906 | ||
|
|
6428cf7359 | ||
|
|
ddd8260e4b | ||
|
|
16c4f9006a | ||
|
|
8a011282a0 | ||
|
|
8e0150d09e | ||
|
|
e78b192e14 | ||
|
|
fd6eece6af | ||
|
|
9e9e0c700c | ||
|
|
8f951556e1 | ||
|
|
7256081ae3 | ||
|
|
cef396d092 | ||
|
|
e0da5edd58 | ||
|
|
88b5c1401b | ||
|
|
fec0004a31 | ||
|
|
545c87fdc3 | ||
|
|
53a3b46fa9 | ||
|
|
88bb4a2b50 | ||
|
|
0b716b8896 | ||
|
|
26b0530302 | ||
|
|
63d98abeb3 | ||
|
|
80b862395d | ||
|
|
9609cb7402 | ||
|
|
c2ca2f57f6 | ||
|
|
69933e25c3 | ||
|
|
b563af4b4c | ||
|
|
0a7c4b3858 | ||
|
|
32c04c038f | ||
|
|
6456fa71d9 | ||
|
|
e2db791e75 | ||
|
|
6c74952077 | ||
|
|
7c0e407e44 | ||
|
|
7dbf2b348c | ||
|
|
129956a65d | ||
|
|
85d1816d03 | ||
|
|
e1919638b3 | ||
|
|
c5c5524d20 | ||
|
|
245ea0c358 | ||
|
|
c54ad571e5 | ||
|
|
ec97ebbe7f | ||
|
|
e19c70013e | ||
|
|
be8f6fd62b | ||
|
|
cf205f35f4 | ||
|
|
4a3b790ce4 | ||
|
|
0420e96a41 | ||
|
|
364d4a4ea1 | ||
|
|
7a11c572e6 | ||
|
|
9b4d42ca64 | ||
|
|
b3ec0cb488 | ||
|
|
b596e0bcaa | ||
|
|
b9f9b3cce6 | ||
|
|
c549c8b66e | ||
|
|
15b507c5c4 | ||
|
|
4ee1651e54 | ||
|
|
9ba974aff4 | ||
|
|
d1bae78189 | ||
|
|
ce74e00e5a | ||
|
|
28a179021e | ||
|
|
1d22ff7fa1 | ||
|
|
22bde0e5ba | ||
|
|
49868d8615 | ||
|
|
486bbf0fe8 | ||
|
|
12a96b9482 | ||
|
|
d11c5467bd | ||
|
|
4f5aa2e40d | ||
|
|
714e5ea65e | ||
|
|
72531d330d | ||
|
|
67e3e0e856 | ||
|
|
1f487eb933 | ||
|
|
94313e9a09 | ||
|
|
40b37c64c8 | ||
|
|
f686b8195b | ||
|
|
043845ce75 | ||
|
|
3a7eef2bcf | ||
|
|
550381b57a | ||
|
|
ca2e8861e5 | ||
|
|
f42f38e1ba | ||
|
|
e264323124 | ||
|
|
8ae798a089 | ||
|
|
90def2bf22 | ||
|
|
86979e36d5 | ||
|
|
168d13713a | ||
|
|
34eab5d7fe | ||
|
|
14ee35a791 | ||
|
|
5c8d40b5f1 | ||
|
|
4e19d810df | ||
|
|
f803f77561 | ||
|
|
2804fa9dfe | ||
|
|
67a8db3650 | ||
|
|
fe4a5b4004 | ||
|
|
ef38390666 | ||
|
|
17434d7263 | ||
|
|
ac53db35e7 | ||
|
|
9d21b524ff | ||
|
|
e33eab40a6 | ||
|
|
a27e5d374a | ||
|
|
096fe67010 | ||
|
|
fe451dd59d | ||
|
|
be63a4fa01 | ||
|
|
322076a8c2 | ||
|
|
d56011ad61 | ||
|
|
b922d0b808 | ||
|
|
76bf3137e0 | ||
|
|
21366a9fe4 | ||
|
|
52f880f405 | ||
|
|
e535d58feb | ||
|
|
83dc547327 | ||
|
|
5117dc2766 | ||
|
|
e700f42138 | ||
|
|
5232246116 | ||
|
|
7835fdcd21 | ||
|
|
76373012fb | ||
|
|
1061125572 | ||
|
|
c5395d23e5 | ||
|
|
d9a4fa4f51 | ||
|
|
60a795575f | ||
|
|
8a06cd7a78 | ||
|
|
c6118eb209 | ||
|
|
50afe2ef5a | ||
|
|
91b1cde5d6 | ||
|
|
baddb6bf42 | ||
|
|
39ff5c4895 | ||
|
|
c1ba5b2ddc | ||
|
|
b2aa4d143f | ||
|
|
0777ef9c2f | ||
|
|
64ab3a383e | ||
|
|
c7d14df920 | ||
|
|
1edc84a38c | ||
|
|
c04ced9c7e | ||
|
|
d6842d3140 | ||
|
|
c53314a3da | ||
|
|
8cfc95f2d3 | ||
|
|
67420d1d08 | ||
|
|
6256f3e8b0 | ||
|
|
1d786cd992 | ||
|
|
1d4b165476 | ||
|
|
b3fd863141 | ||
|
|
34b6e1f80c | ||
|
|
9e5ad597cb | ||
|
|
b53a582daa | ||
|
|
2a644ae7ae | ||
|
|
aff32728ca | ||
|
|
ecc6e79407 | ||
|
|
49762d28e4 | ||
|
|
4a2fad0d04 | ||
|
|
2d130bfba2 | ||
|
|
d5eb5a23c6 | ||
|
|
73a6762fe2 | ||
|
|
952b7dec91 | ||
|
|
74b8ab5db1 | ||
|
|
33ebd79ac3 | ||
|
|
1507765a2c | ||
|
|
07edc56551 | ||
|
|
589b2ce815 | ||
|
|
5e06732b2f | ||
|
|
80b8d5adac | ||
|
|
4f32c39eb8 | ||
|
|
e6d377d21d | ||
|
|
74a4730073 | ||
|
|
ccd68cb4ed | ||
|
|
0b6f33033b | ||
|
|
688490dfe9 | ||
|
|
ef96e593a3 | ||
|
|
d8700e8d4e | ||
|
|
5a25a05a7d | ||
|
|
d66b82cb74 | ||
|
|
23ad42d1ff | ||
|
|
4ca6885368 | ||
|
|
632b53edde | ||
|
|
153c683120 | ||
|
|
5446c47c1d | ||
|
|
3e5210342a | ||
|
|
2b63c668ec | ||
|
|
63084d78a4 | ||
|
|
6d0c155ea6 | ||
|
|
7d07e8118f | ||
|
|
638c50734b | ||
|
|
862f877c76 | ||
|
|
900f0acd81 | ||
|
|
7afcf8fab0 | ||
|
|
fe20276c43 | ||
|
|
9b0301345b | ||
|
|
6bfdda4c5b | ||
|
|
eddb899050 | ||
|
|
acea663034 | ||
|
|
072b51c7df | ||
|
|
03464f06d2 | ||
|
|
d9fb825c63 | ||
|
|
7066669f5d | ||
|
|
61a922a642 | ||
|
|
4294a7c908 | ||
|
|
d2039d7fac | ||
|
|
d93cedad7f | ||
|
|
b2ce4125f6 | ||
|
|
3ec576ec1d | ||
|
|
5216190247 | ||
|
|
c9a8c128bb | ||
|
|
4dd625a93f | ||
|
|
278409db05 | ||
|
|
ed760d1567 | ||
|
|
2bbf07b25e | ||
|
|
5cdd66700b | ||
|
|
8b51d9ec73 | ||
|
|
1f56a6d5c9 | ||
|
|
4482da4833 | ||
|
|
a824fbfd08 | ||
|
|
013c71ae63 | ||
|
|
0741d52cd7 | ||
|
|
fc3999af09 | ||
|
|
62565a77c0 | ||
|
|
5089fb723e | ||
|
|
da45303c18 | ||
|
|
e1b71fbc54 | ||
|
|
4bfa07a929 | ||
|
|
76e80fe630 | ||
|
|
7807354bfd | ||
|
|
b186e3c87e | ||
|
|
283a57a3df | ||
|
|
03b08b2c3b | ||
|
|
a874d36015 | ||
|
|
ea392b914f | ||
|
|
569340c6ad | ||
|
|
d8b3f2d7e4 | ||
|
|
b9c1ee97e9 | ||
|
|
51833bec14 | ||
|
|
73e135d013 | ||
|
|
e453eebe3f | ||
|
|
282cf7d706 | ||
|
|
224d21ea3d | ||
|
|
0846c9d221 | ||
|
|
2cabb02098 | ||
|
|
2075139ce5 | ||
|
|
20b4399d5d | ||
|
|
bf16d23d81 | ||
|
|
027d8808b7 | ||
|
|
24ffd57dfa | ||
|
|
9941c48914 | ||
|
|
76e67908ce | ||
|
|
91676a619a | ||
|
|
65f9d2ae9e | ||
|
|
33070fb881 | ||
|
|
3c8b63ea6c | ||
|
|
01a445a418 | ||
|
|
a74116c82c | ||
|
|
f8ef2e4efe | ||
|
|
a884bca7a1 | ||
|
|
a484f30bc5 | ||
|
|
e0cf1e0ae7 | ||
|
|
eb1077bc4c | ||
|
|
d7db851253 | ||
|
|
d220385c53 | ||
|
|
04447d302c | ||
|
|
14089c9360 | ||
|
|
83efef15f3 | ||
|
|
881254182e | ||
|
|
04f1fe7fbf | ||
|
|
5f55b8aaf7 | ||
|
|
e5e387da9e | ||
|
|
bda773c963 | ||
|
|
2f7e6c3a5d | ||
|
|
b434310383 | ||
|
|
550db27a1c | ||
|
|
5ce8853ccb | ||
|
|
1c1f68e8dc | ||
|
|
443683525f | ||
|
|
88296d994d | ||
|
|
eee3bce748 | ||
|
|
6466714e4c | ||
|
|
7df71a2525 | ||
|
|
28e51005dc | ||
|
|
fbe19e90b9 | ||
|
|
db0ec1ab0f | ||
|
|
ac0c3e60fb | ||
|
|
9d8f7aed0e | ||
|
|
3fe1664601 | ||
|
|
cc3b821f66 | ||
|
|
2692cf4f03 | ||
|
|
b691f7448f | ||
|
|
dec8b62796 | ||
|
|
44550c374f | ||
|
|
d7d9b81a85 | ||
|
|
d128b45c6f | ||
|
|
e2a70ac0ea | ||
|
|
b062596fd4 | ||
|
|
5014781d21 | ||
|
|
923aee7cf5 | ||
|
|
04ebe6d8c1 | ||
|
|
445ded0e3b | ||
|
|
de4c0127ad | ||
|
|
48949f35c5 | ||
|
|
a8fc7d80e2 | ||
|
|
ceb282a46d | ||
|
|
1668ccb2b0 | ||
|
|
95cf873e53 | ||
|
|
7d5498de1b | ||
|
|
e2c648e93c | ||
|
|
ca8ddfda02 | ||
|
|
a53e45ada0 | ||
|
|
c07ed1a498 | ||
|
|
f87407034d | ||
|
|
6f26178a3a | ||
|
|
7480eb2317 | ||
|
|
933898b457 | ||
|
|
5d08b299a7 | ||
|
|
6165c49f1d | ||
|
|
20587a4733 | ||
|
|
6a89bc9be0 | ||
|
|
ba488ce64f | ||
|
|
b06fd4b36d | ||
|
|
2d37da10db | ||
|
|
b46d90e09d | ||
|
|
4b11e25746 | ||
|
|
1d74e43b2c | ||
|
|
27ce7a9151 | ||
|
|
a9578c9d5b | ||
|
|
b82f13546f | ||
|
|
3979c734a2 | ||
|
|
24f27f81a5 | ||
|
|
9c7d8a941d | ||
|
|
f05fe34a85 | ||
|
|
ea6c7f4edb | ||
|
|
a7cb3ace36 | ||
|
|
89defaa712 | ||
|
|
24dd09fea7 | ||
|
|
1d108d8f6a | ||
|
|
60ec3c6b37 | ||
|
|
55a788e756 | ||
|
|
1cf81c1aa9 | ||
|
|
457730dded | ||
|
|
d81d9e260f | ||
|
|
c577b82875 | ||
|
|
2d049e8df6 | ||
|
|
cd65b60960 | ||
|
|
b52288cbcf | ||
|
|
4327cde28b | ||
|
|
08c320d047 | ||
|
|
2b5c43029e | ||
|
|
c8c879f1c5 | ||
|
|
a107f6d12e | ||
|
|
4717d2480c | ||
|
|
91dc94cec6 | ||
|
|
1f605930cc | ||
|
|
c7020c017d | ||
|
|
9b025df36b | ||
|
|
b0b1303207 | ||
|
|
4f20847f8b | ||
|
|
3e95d99fe2 | ||
|
|
1dce444f70 | ||
|
|
4dfe234950 | ||
|
|
8ecaaddd23 | ||
|
|
a793486541 | ||
|
|
6b85431df6 | ||
|
|
32edcfc9cd | ||
|
|
a28dc34918 | ||
|
|
3135f888f0 | ||
|
|
84fc62f30f | ||
|
|
c4c7e0a966 | ||
|
|
918037bd30 | ||
|
|
5fe354bc1e | ||
|
|
9a9a6cf10b | ||
|
|
6ac0bbfd17 | ||
|
|
75e9127216 | ||
|
|
1d099c001f | ||
|
|
ffa70704ca | ||
|
|
71f0c6fef9 | ||
|
|
a6bdb0022f | ||
|
|
1d93d28494 | ||
|
|
c3d43193c9 | ||
|
|
da9a658e35 | ||
|
|
3bc9d9caa7 | ||
|
|
d5059c91f5 | ||
|
|
ec4c0f1dd6 | ||
|
|
4d99f2bdd4 | ||
|
|
ce1f57e940 | ||
|
|
2fbe0cd333 | ||
|
|
747d65133a | ||
|
|
195b03e196 | ||
|
|
c023d53f02 | ||
|
|
c1f0b4e9da | ||
|
|
26d060797c | ||
|
|
118b93c591 | ||
|
|
654829da66 | ||
|
|
88e29060cd | ||
|
|
a7b81a60c0 | ||
|
|
db985af3c3 | ||
|
|
2c16a6bb9d | ||
|
|
b4949fd8c6 | ||
|
|
206bc2a330 | ||
|
|
2c00d750c2 | ||
|
|
ae79e023d5 | ||
|
|
bef7ae4800 | ||
|
|
b7d7f47a5e | ||
|
|
85de53c450 | ||
|
|
96d39380fa | ||
|
|
d5a769ec89 | ||
|
|
869d26c3b4 | ||
|
|
c3f2c6b19d | ||
|
|
465d35a78a | ||
|
|
bf3f9cffc2 | ||
|
|
4b7f7b371b | ||
|
|
0dd4ff1bc8 | ||
|
|
577818e419 | ||
|
|
2589ed586d | ||
|
|
b9ce809aaf | ||
|
|
dd01e016a6 | ||
|
|
329b107606 | ||
|
|
fb7b8f201f | ||
|
|
74da40520c | ||
|
|
f5f0256d82 | ||
|
|
25bdc55fb8 | ||
|
|
f5f1c749b6 | ||
|
|
951b243d17 | ||
|
|
a9b2d841f7 | ||
|
|
58d6f4fac6 | ||
|
|
03846d6916 | ||
|
|
774a94b6c2 | ||
|
|
283dbc30ee | ||
|
|
f4374bd168 | ||
|
|
87958ea037 | ||
|
|
52235eadfd | ||
|
|
cb963b09ab | ||
|
|
1fb75eaa9e | ||
|
|
a71a787038 | ||
|
|
cbc450860e | ||
|
|
ecdc185deb | ||
|
|
cc2e5cc3d7 | ||
|
|
5c2a88a9a1 | ||
|
|
5bc9daa125 | ||
|
|
21a4e7a826 | ||
|
|
556bd43a26 | ||
|
|
8426fafe90 | ||
|
|
7ae3bbee25 | ||
|
|
bada298857 | ||
|
|
5a540f778a | ||
|
|
bed4c0595c | ||
|
|
0c89348be4 | ||
|
|
53d16f86fd | ||
|
|
ecd66274a7 | ||
|
|
586f487ea9 | ||
|
|
03e7900edb | ||
|
|
345329e079 | ||
|
|
f5798f729d | ||
|
|
dcd34ab6c1 | ||
|
|
8a78b2497a | ||
|
|
58d66ad47f | ||
|
|
f6448ff595 | ||
|
|
4421c71120 | ||
|
|
9a6ef44a06 | ||
|
|
ae5ebe3d92 | ||
|
|
0c59b3c71f | ||
|
|
6e58219117 | ||
|
|
6259f15e33 | ||
|
|
e48635bd59 | ||
|
|
cf592f29bc | ||
|
|
00e9080314 | ||
|
|
17336bc8ee | ||
|
|
1df0e8a012 | ||
|
|
66a279df53 | ||
|
|
5eb67ed4e2 | ||
|
|
fcd42c1e28 | ||
|
|
c99abadafb | ||
|
|
8753a838cf | ||
|
|
749e809478 | ||
|
|
fb37b44e79 | ||
|
|
8f8a26c091 | ||
|
|
c2e9167e45 | ||
|
|
13ef94ad46 | ||
|
|
c2388bf09b | ||
|
|
b52ea6bd8f | ||
|
|
bdf263625d | ||
|
|
8c7bbbfc21 | ||
|
|
15631e02a2 | ||
|
|
1907f72934 | ||
|
|
ba62748217 | ||
|
|
224ace32be | ||
|
|
3ef748abb3 | ||
|
|
3f8b8d754c | ||
|
|
7a18e4e00b | ||
|
|
60ed71459c | ||
|
|
7b39bbaa91 | ||
|
|
2927c4ce76 | ||
|
|
3e47b3002b | ||
|
|
1bac6d567f | ||
|
|
92cfbf16c2 | ||
|
|
b445b26164 | ||
|
|
832c503c92 | ||
|
|
076d7fd63a | ||
|
|
3ed71070a3 | ||
|
|
08dbefedc7 | ||
|
|
4be377650e | ||
|
|
8898803b4a | ||
|
|
21f71d72f0 | ||
|
|
d79061e0c6 | ||
|
|
d951c560e4 | ||
|
|
6cf782b75c | ||
|
|
dca0f7315c | ||
|
|
0983d2dbcf | ||
|
|
d90cbec236 | ||
|
|
6e20d410bb | ||
|
|
b4f6460bff | ||
|
|
199056cf1b | ||
|
|
681c68c62a | ||
|
|
cc41ec258f | ||
|
|
3c0906ca24 | ||
|
|
60a3655469 | ||
|
|
15df676d2e | ||
|
|
e5276bbbe7 | ||
|
|
12ab5baff4 | ||
|
|
f120c1b78e | ||
|
|
421bb8c53a | ||
|
|
9fea8ec6c8 | ||
|
|
536f826b56 | ||
|
|
307b4ebcc9 | ||
|
|
e1a9eb13b1 | ||
|
|
51fe7e466e | ||
|
|
8403a28adc | ||
|
|
c4f8466d5d | ||
|
|
cc5889c543 | ||
|
|
9e88467485 | ||
|
|
bfb3852942 | ||
|
|
df4356133d | ||
|
|
814be45aa8 | ||
|
|
bab9227e9d | ||
|
|
2f1ce9169d | ||
|
|
b19f202542 | ||
|
|
71f12283d9 | ||
|
|
4c5882258c | ||
|
|
ce24114a01 | ||
|
|
8e79c9fd30 | ||
|
|
5372e66c0c | ||
|
|
94dbf619d3 | ||
|
|
9d7ceac1f3 | ||
|
|
6a992382a4 | ||
|
|
c93d0c4f30 | ||
|
|
f2010e5532 | ||
|
|
5dce7c21e3 | ||
|
|
382f1519b2 | ||
|
|
38914dfe6a | ||
|
|
f65d629541 | ||
|
|
7608eda1ff | ||
|
|
21d9b85d66 | ||
|
|
44fa2c83d1 | ||
|
|
bad1080586 | ||
|
|
992e11b852 | ||
|
|
043c249458 | ||
|
|
d551e19b18 | ||
|
|
58720d608e | ||
|
|
3c7f275f4f | ||
|
|
77d6143485 | ||
|
|
d0fc12db61 | ||
|
|
ae17ce5b03 | ||
|
|
8794c51389 | ||
|
|
8a1c16bf09 | ||
|
|
1f65b2901b | ||
|
|
9be069fb98 | ||
|
|
b194f66fbc | ||
|
|
1d4e8c958d | ||
|
|
b071f10dd7 | ||
|
|
44f63165cb | ||
|
|
cc01d1be33 | ||
|
|
66cee497e7 | ||
|
|
7251f6a6e9 | ||
|
|
f7837682b4 | ||
|
|
41f21520d1 | ||
|
|
e5efe5f568 | ||
|
|
396ab3eba1 | ||
|
|
01ad9af590 | ||
|
|
5d2f6c07c3 | ||
|
|
6cab7064a0 | ||
|
|
6f80ed8615 | ||
|
|
88d49edda5 | ||
|
|
5f705664fa | ||
|
|
6fba1f1fad | ||
|
|
127af0ffc7 | ||
|
|
86f72d0830 | ||
|
|
9423829db2 | ||
|
|
f8a698e9af | ||
|
|
807244badd | ||
|
|
2106bf5085 | ||
|
|
2debcef8f6 | ||
|
|
7cdcb4f696 | ||
|
|
8f8e215df1 | ||
|
|
0c56ee7a89 | ||
|
|
dfebed11c2 | ||
|
|
0394bae0e3 | ||
|
|
1e4828d9fc | ||
|
|
108f25350d | ||
|
|
f40b5b5c47 | ||
|
|
b38bbde2fe | ||
|
|
939071d737 | ||
|
|
42d7d0adad | ||
|
|
14e6a69a46 | ||
|
|
b1e1ccf632 | ||
|
|
7b78757c6f | ||
|
|
7d3cf9565e | ||
|
|
86cc1d4e67 | ||
|
|
80d09bfbb3 | ||
|
|
615ae2f497 | ||
|
|
1c3b4af564 | ||
|
|
40cc8fa45f | ||
|
|
ea61ddb0d0 | ||
|
|
9f975293e1 | ||
|
|
d40393fde7 | ||
|
|
8517e99816 | ||
|
|
cf07f0cab1 | ||
|
|
ddb58dd9f3 | ||
|
|
7d9ded56a2 | ||
|
|
e75e8dcbeb | ||
|
|
4a0a534357 | ||
|
|
d441128bf6 | ||
|
|
891e087926 | ||
|
|
9d385ef326 | ||
|
|
3b80d4dcd7 | ||
|
|
343033bf06 | ||
|
|
b688bb301c | ||
|
|
9138b45e82 | ||
|
|
1b7f871819 | ||
|
|
52e45997db | ||
|
|
45547d1c3b | ||
|
|
0f520b8cc0 | ||
|
|
5478d76271 | ||
|
|
57a1ebb809 | ||
|
|
dfb5cc306f | ||
|
|
ea880f2e2c | ||
|
|
68faf9d1b9 | ||
|
|
5597ca70be | ||
|
|
4b9d48a150 | ||
|
|
6b19617333 | ||
|
|
86d696d933 | ||
|
|
e685ca9126 | ||
|
|
abaa9a8760 | ||
|
|
ebabd2f8cd | ||
|
|
c51e8a1523 | ||
|
|
9fb898943a | ||
|
|
ccd781d97e | ||
|
|
9db68fcf5d | ||
|
|
219e838070 | ||
|
|
720ce5aa70 | ||
|
|
a0a8f2a451 | ||
|
|
67cc922747 | ||
|
|
75e6399261 | ||
|
|
25528eacbc | ||
|
|
f6b619aab1 | ||
|
|
7547d0d8e5 | ||
|
|
d7a6c95464 | ||
|
|
9687b35d83 | ||
|
|
173d065a9e | ||
|
|
67cbe6d471 | ||
|
|
c625bc88aa | ||
|
|
f1f599d775 | ||
|
|
c4b719d4dc | ||
|
|
e23690a0dc | ||
|
|
20d2398ab6 | ||
|
|
32cadeacdb | ||
|
|
a3c0d68af9 | ||
|
|
24cf5c7a5e | ||
|
|
8ea1ee14d5 | ||
|
|
ec029f66cc | ||
|
|
ba6ca7ff71 | ||
|
|
eb9f4efde7 | ||
|
|
8ee93720ce | ||
|
|
cea00b4b21 | ||
|
|
f3c9508e95 | ||
|
|
23de673537 | ||
|
|
26870ad27b | ||
|
|
54ee110436 | ||
|
|
a011a23090 | ||
|
|
0d4c994471 | ||
|
|
bc1d59ee19 | ||
|
|
3a6584b2ee | ||
|
|
c650249339 | ||
|
|
516aa96419 | ||
|
|
1808ecb348 | ||
|
|
74c29b391a | ||
|
|
33f54bfaa1 | ||
|
|
5131a43f96 | ||
|
|
62135da3ba | ||
|
|
7fbbb535ff | ||
|
|
bda788e932 | ||
|
|
ec44f2af6d | ||
|
|
6059444c84 | ||
|
|
814bf1ca0c | ||
|
|
aaa496213e | ||
|
|
c66f40f749 | ||
|
|
e921abf260 | ||
|
|
d893ab6428 | ||
|
|
dbb67824a4 | ||
|
|
592abf8ee7 | ||
|
|
2a411dd248 | ||
|
|
909d647801 | ||
|
|
243be87c6d | ||
|
|
eab4ffa721 | ||
|
|
1e0f0a35cf | ||
|
|
d4aebaa671 | ||
|
|
cd5189a63c | ||
|
|
cf50a83b8d | ||
|
|
89746fa70f | ||
|
|
e1c2c42c24 | ||
|
|
05c133a9c3 | ||
|
|
92bda144d9 | ||
|
|
6eeb2898f7 | ||
|
|
e974383cba | ||
|
|
7912baea69 | ||
|
|
07389fd9fc | ||
|
|
7a4aef0d0d | ||
|
|
85fd90d4c2 | ||
|
|
6080ab547d | ||
|
|
6562466c9e | ||
|
|
904c6e767b | ||
|
|
58634bda69 | ||
|
|
cb10a45ded | ||
|
|
90007f7087 | ||
|
|
39ddfdd9a2 | ||
|
|
ab4ea744f9 | ||
|
|
60cc2fe911 | ||
|
|
74ea71b324 | ||
|
|
3d748e93f1 | ||
|
|
a5d7fc84ee | ||
|
|
e8a8d005f0 | ||
|
|
2f4c61d1be | ||
|
|
677dd27912 | ||
|
|
689f5cc187 | ||
|
|
8f8d9a9dde | ||
|
|
634b107491 | ||
|
|
31ba751d2e | ||
|
|
c8b2a3dc13 | ||
|
|
58313419e2 | ||
|
|
8e598ea5c6 | ||
|
|
58f0298c62 | ||
|
|
f98e6c1955 | ||
|
|
a2f7b34f38 | ||
|
|
fad173a0f9 | ||
|
|
c1a9d1c0e0 | ||
|
|
3cf363384e | ||
|
|
bff0662ba3 | ||
|
|
8b6749dedd | ||
|
|
00095e3cbd | ||
|
|
6890805b16 | ||
|
|
c654fdf709 | ||
|
|
c060f4ac3d | ||
|
|
23d3e70b4e | ||
|
|
d945077f42 | ||
|
|
6607ffb9ec | ||
|
|
ad5902bc39 | ||
|
|
5247dc3cd2 | ||
|
|
b340601ef6 | ||
|
|
0f6081ee26 | ||
|
|
c17797f979 | ||
|
|
6638d49ad9 | ||
|
|
659ff22ea4 | ||
|
|
442d78a556 | ||
|
|
a599587fce | ||
|
|
9483255583 | ||
|
|
b3d37a908c | ||
|
|
e039795971 | ||
|
|
47d0f21c60 | ||
|
|
a88d821d9f | ||
|
|
460c4c2b9a | ||
|
|
3bf315d70e | ||
|
|
5d3920f5ab | ||
|
|
69208fc62a | ||
|
|
484a5b38af | ||
|
|
f112083c7a | ||
|
|
2ef148d1ee | ||
|
|
818ef42d22 | ||
|
|
d77b28e90b | ||
|
|
2183e55c12 | ||
|
|
b3d3ae42ed | ||
|
|
61924171bf | ||
|
|
20a081eb37 | ||
|
|
7dbf29a10d | ||
|
|
440543aa88 | ||
|
|
4725941c74 | ||
|
|
f14d0ef339 | ||
|
|
c595c27357 | ||
|
|
6d378bf78e | ||
|
|
23c4d31291 | ||
|
|
6af9f59010 | ||
|
|
571d1f7314 | ||
|
|
dd29092472 | ||
|
|
3a48eef3c8 | ||
|
|
f80da18f2e | ||
|
|
c4c800416f | ||
|
|
a6e4c9210d | ||
|
|
764519245b | ||
|
|
902a15d149 | ||
|
|
3e61ccc2d4 | ||
|
|
3aaf9abb73 | ||
|
|
e348891410 | ||
|
|
45469fbde9 | ||
|
|
0bc349c450 | ||
|
|
6aacfdb9ba | ||
|
|
5aa1c3547e | ||
|
|
c1c31f2cba | ||
|
|
79707ca3ee | ||
|
|
5fcb784294 | ||
|
|
0a1e5eb93b | ||
|
|
826d2ac716 | ||
|
|
878644b358 | ||
|
|
ef4efcced1 | ||
|
|
9e1a44e6bb | ||
|
|
7819816cc9 | ||
|
|
087c4c8b3c | ||
|
|
b370918e0c | ||
|
|
e6ad21933b | ||
|
|
22b96dd414 | ||
|
|
aa2edb427a | ||
|
|
39d6f49896 | ||
|
|
e0a82f4921 | ||
|
|
b95a23ce78 | ||
|
|
7842c19934 | ||
|
|
fef495942a | ||
|
|
b7d480986a | ||
|
|
da6a30b022 | ||
|
|
bca912f91e | ||
|
|
5b77fff586 | ||
|
|
95db5bab42 | ||
|
|
b4c1356d18 | ||
|
|
668dd47700 | ||
|
|
d9bcda01db | ||
|
|
8c50a04455 | ||
|
|
80b849e2a0 | ||
|
|
e15a7d1f7e | ||
|
|
7da8884581 | ||
|
|
871523c8f4 | ||
|
|
09172b112f | ||
|
|
3adc4a6e0e | ||
|
|
b29bf7515b | ||
|
|
cba62feeec | ||
|
|
09c6d53e64 | ||
|
|
78aa706491 | ||
|
|
f50d542ff7 | ||
|
|
583d7205c6 | ||
|
|
1f1dba92a8 | ||
|
|
258e591e45 | ||
|
|
42d27cd152 | ||
|
|
d8d6c7a07b | ||
|
|
4f0163fd38 | ||
|
|
0244879c8f | ||
|
|
743e4c6231 | ||
|
|
c3d99b5292 | ||
|
|
d1f519e0cd | ||
|
|
ff3cec5beb | ||
|
|
b0deadc05d | ||
|
|
ced4ef9ad6 | ||
|
|
ca19ae5ad0 | ||
|
|
9460263e41 | ||
|
|
197ecabb9a | ||
|
|
ee459684f1 | ||
|
|
6516c72ef1 | ||
|
|
9d022818e1 | ||
|
|
b9ae9f5f38 | ||
|
|
b8ac9e1597 | ||
|
|
9537b240de | ||
|
|
9c6de78844 | ||
|
|
6bb4fea31d | ||
|
|
97849a08cd | ||
|
|
2f435912d8 | ||
|
|
d737dc6dd2 | ||
|
|
1b22f12acd | ||
|
|
69bb9e3c8c | ||
|
|
772b5f9a5a | ||
|
|
64acaca8ee | ||
|
|
0008beb1fb | ||
|
|
846b5ea252 | ||
|
|
de0b0b3705 | ||
|
|
4dec99c61e | ||
|
|
18d715b86e | ||
|
|
a157791264 | ||
|
|
590d82bc33 | ||
|
|
a210dacdf4 | ||
|
|
1dfaa528f8 | ||
|
|
8c811778d6 | ||
|
|
395ae75eb3 | ||
|
|
2606966b43 | ||
|
|
c98f0e6631 | ||
|
|
a7714585bb | ||
|
|
da6e4853be | ||
|
|
afba0f3da7 | ||
|
|
d2b947c351 | ||
|
|
d1ba51bc84 | ||
|
|
9d73b2339a | ||
|
|
e88c96b1d7 | ||
|
|
3655e30adb | ||
|
|
112a400662 | ||
|
|
33a9603e93 | ||
|
|
ae6dfa9dae | ||
|
|
c05ae26ec8 | ||
|
|
3b2f29ef69 | ||
|
|
ecb61403d7 | ||
|
|
9eb37bff49 | ||
|
|
605109021f | ||
|
|
a3b7699f42 | ||
|
|
3251460ebd | ||
|
|
ec036ed185 | ||
|
|
5922ea1a0c | ||
|
|
1fb7d64171 | ||
|
|
fd8aa077e3 | ||
|
|
3e8a2aaddb | ||
|
|
c81c29ae58 | ||
|
|
5b4b6e7999 | ||
|
|
f565c92e38 | ||
|
|
fc4bf8158a | ||
|
|
7cd3aa7a1e | ||
|
|
ab4057880e | ||
|
|
d72885b383 | ||
|
|
fd1476e3aa | ||
|
|
142e4ebb57 | ||
|
|
ca92b9104c | ||
|
|
a6179d03f3 | ||
|
|
8afaf0380f | ||
|
|
ca0c409b6f | ||
|
|
177796ff79 | ||
|
|
da3be881ba | ||
|
|
1a0ec77094 | ||
|
|
e226021c5e | ||
|
|
1942c6a035 | ||
|
|
c49166401a | ||
|
|
500c0003b2 | ||
|
|
0275d77fc0 | ||
|
|
67a4b12e27 | ||
|
|
d1c08f11d5 | ||
|
|
40c0867f63 | ||
|
|
7081a85ace |
6
.babelrc
6
.babelrc
@@ -2,8 +2,9 @@
|
||||
"presets": ["react"],
|
||||
"ignore": ["third_party"],
|
||||
"plugins": [
|
||||
"fbjs-scripts/babel-6/dev-expression",
|
||||
"transform-class-properties",
|
||||
"syntax-trailing-function-commas",
|
||||
"transform-object-rest-spread",
|
||||
"transform-es2015-template-literals",
|
||||
"transform-es2015-literals",
|
||||
"transform-es2015-arrow-functions",
|
||||
@@ -21,6 +22,7 @@
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-es3-member-expression-literals",
|
||||
"transform-es3-property-literals",
|
||||
"./scripts/babel/transform-object-assign-require"
|
||||
"./scripts/babel/transform-object-assign-require",
|
||||
"transform-react-jsx-source"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# We can probably lint these later but not important at this point
|
||||
addons/**/node_modules/
|
||||
src/renderers/art
|
||||
src/shared/vendor
|
||||
# But not in docs/_js/examples/*
|
||||
docs/_js/*.js
|
||||
@@ -9,6 +11,7 @@ docs/vendor/bundle/
|
||||
# This should be more like examples/**/thirdparty/** but
|
||||
# we should fix https://github.com/facebook/esprima/pull/85 first
|
||||
examples/
|
||||
fixtures/
|
||||
# Ignore built files.
|
||||
build/
|
||||
coverage/
|
||||
|
||||
31
.eslintrc.js
31
.eslintrc.js
@@ -3,67 +3,50 @@ const WARNING = 1;
|
||||
const ERROR = 2;
|
||||
|
||||
module.exports = {
|
||||
parser: 'babel-eslint',
|
||||
|
||||
extends: './node_modules/fbjs-scripts/eslint/.eslintrc.js',
|
||||
extends: 'fbjs',
|
||||
|
||||
plugins: [
|
||||
'react',
|
||||
'react-internal',
|
||||
],
|
||||
|
||||
ecmaFeatures: {
|
||||
modules: false
|
||||
},
|
||||
|
||||
// We're stricter than the default config, mostly. We'll override a few rules
|
||||
// and then enable some React specific ones.
|
||||
rules: {
|
||||
'accessor-pairs': OFF,
|
||||
'brace-style': [ERROR, '1tbs'],
|
||||
'comma-dangle': [ERROR, 'always-multiline'],
|
||||
'consistent-return': ERROR,
|
||||
'consistent-return': OFF,
|
||||
'dot-location': [ERROR, 'property'],
|
||||
'dot-notation': ERROR,
|
||||
'eol-last': ERROR,
|
||||
'eqeqeq': [ERROR, 'allow-null'],
|
||||
'indent': [ERROR, 2, {SwitchCase: 1}],
|
||||
'indent': OFF, // We use Prettier now
|
||||
'jsx-quotes': [ERROR, 'prefer-double'],
|
||||
'keyword-spacing': [ERROR, {after: true, before: true}],
|
||||
'no-bitwise': OFF,
|
||||
'no-inner-declarations': [ERROR, 'functions'],
|
||||
'no-multi-spaces': ERROR,
|
||||
'no-restricted-syntax': [ERROR, 'WithStatement'],
|
||||
'no-shadow': ERROR,
|
||||
'no-unused-expressions': ERROR,
|
||||
'no-unused-vars': [ERROR, {args: 'none'}],
|
||||
'quotes': [ERROR, 'single', 'avoid-escape'],
|
||||
'space-after-keywords': ERROR,
|
||||
'quotes': [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true }],
|
||||
'space-before-blocks': ERROR,
|
||||
'space-before-function-paren': [ERROR, {anonymous: 'never', named: 'never'}],
|
||||
'space-before-keywords': ERROR,
|
||||
'strict': [ERROR, 'global'],
|
||||
|
||||
// React & JSX
|
||||
// Our transforms set this automatically
|
||||
'react/display-name': OFF,
|
||||
'react/jsx-boolean-value': [ERROR, 'always'],
|
||||
'react/jsx-no-undef': ERROR,
|
||||
// We don't care to do this
|
||||
'react/jsx-sort-prop-types': OFF,
|
||||
'react/jsx-sort-props': OFF,
|
||||
'react/jsx-uses-react': ERROR,
|
||||
'react/jsx-uses-vars': ERROR,
|
||||
// It's easier to test some things this way
|
||||
'react/no-did-mount-set-state': OFF,
|
||||
'react/no-did-update-set-state': OFF,
|
||||
// We define multiple components in test files
|
||||
'react/no-multi-comp': OFF,
|
||||
'react/no-unknown-property': OFF,
|
||||
'react/no-is-mounted': OFF,
|
||||
// This isn't useful in our test code
|
||||
'react/prop-types': OFF,
|
||||
'react/react-in-jsx-scope': ERROR,
|
||||
'react/self-closing-comp': ERROR,
|
||||
// We don't care to do this
|
||||
'react/sort-comp': OFF,
|
||||
'react/wrap-multilines': [ERROR, {declaration: false, assignment: false}],
|
||||
|
||||
// CUSTOM RULES
|
||||
|
||||
43
.flowconfig
Normal file
43
.flowconfig
Normal file
@@ -0,0 +1,43 @@
|
||||
[ignore]
|
||||
|
||||
<PROJECT_ROOT>/examples/.*
|
||||
<PROJECT_ROOT>/fixtures/.*
|
||||
<PROJECT_ROOT>/build/.*
|
||||
<PROJECT_ROOT>/node_modules/chrome-devtools-frontend/.*
|
||||
<PROJECT_ROOT>/.*/node_modules/chrome-devtools-frontend/.*
|
||||
<PROJECT_ROOT>/.*/node_modules/y18n/.*
|
||||
<PROJECT_ROOT>/.*/__mocks__/.*
|
||||
<PROJECT_ROOT>/.*/__tests__/.*
|
||||
<PROJECT_ROOT>/addons/.*
|
||||
|
||||
# Ignore Docs
|
||||
<PROJECT_ROOT>/docs/.*
|
||||
<PROJECT_ROOT>/.*/docs/.*
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
./node_modules/fbjs/flow/lib/dev.js
|
||||
./flow
|
||||
|
||||
[options]
|
||||
module.system=haste
|
||||
|
||||
esproposal.class_static_fields=enable
|
||||
esproposal.class_instance_fields=enable
|
||||
|
||||
munge_underscores=false
|
||||
|
||||
suppress_type=$FlowIssue
|
||||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FixMe
|
||||
suppress_type=$FlowExpectedError
|
||||
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||
|
||||
[version]
|
||||
^0.37.0
|
||||
|
||||
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
**Before submitting a pull request,** please make sure the following is done:
|
||||
|
||||
1. Fork [the repository](https://github.com/facebook/react) and create your branch from `master`.
|
||||
2. If you've added code that should be tested, add tests!
|
||||
3. If you've changed APIs, update the documentation.
|
||||
4. Ensure the test suite passes (`npm test`).
|
||||
5. Make sure your code lints (`npm run lint`).
|
||||
6. Format your code with [prettier](https://github.com/prettier/prettier) (`npm run prettier`).
|
||||
7. Run the [Flow](https://flowtype.org/) typechecks (`npm run flow`).
|
||||
8. If you added or removed any tests, run `./scripts/fiber/record-tests` before submitting the pull request, and commit the resulting changes.
|
||||
9. If you haven't already, complete the CLA.
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -15,9 +15,15 @@ docs/code
|
||||
docs/_site
|
||||
docs/.sass-cache
|
||||
docs/js/*
|
||||
docs/downloads
|
||||
docs/downloads/*.zip
|
||||
docs/vendor/bundle
|
||||
<<<<<<< HEAD
|
||||
examples/shared/*.js
|
||||
examples/**/bundle.js
|
||||
=======
|
||||
fixtures/dom/public/react-dom.js
|
||||
fixtures/dom/public/react.js
|
||||
>>>>>>> 4a37718... Remove examples/ folder (#9323)
|
||||
test/the-files-to-test.generated.js
|
||||
*.log*
|
||||
chrome-user-data
|
||||
|
||||
43
.travis.yml
43
.travis.yml
@@ -1,8 +1,11 @@
|
||||
---
|
||||
sudo: required
|
||||
dist: trusty
|
||||
language: node_js
|
||||
node_js:
|
||||
- 4
|
||||
sudo: false
|
||||
rvm:
|
||||
- 2.2.3
|
||||
cache:
|
||||
directories:
|
||||
- docs/vendor/bundle
|
||||
@@ -25,8 +28,8 @@ script:
|
||||
|
||||
GH_PAGES_DIR="$TRAVIS_BUILD_DIR"/../react-gh-pages
|
||||
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" >~/.netrc
|
||||
git config --global user.name "Travis CI"
|
||||
git config --global user.email "travis@reactjs.org"
|
||||
git config --global user.name "$GITHUB_USER_NAME"
|
||||
git config --global user.email "$GITHUB_USER_EMAIL"
|
||||
|
||||
git clone --branch gh-pages --depth=50 \
|
||||
https://reactjs-bot@github.com/facebook/react.git \
|
||||
@@ -36,7 +39,7 @@ script:
|
||||
bundle exec rake release
|
||||
cd $GH_PAGES_DIR
|
||||
git status
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
if test -n "$(git status --porcelain)"; then
|
||||
git add -A .
|
||||
git commit -m "Rebuild website"
|
||||
git push origin gh-pages
|
||||
@@ -58,6 +61,7 @@ script:
|
||||
-F "react-dom-server.min=@build/react-dom-server.min.js" \
|
||||
-F "npm-react=@build/packages/react.tgz" \
|
||||
-F "npm-react-dom=@build/packages/react-dom.tgz" \
|
||||
-F "npm-react-native=@build/packages/react-native-renderer.tgz" \
|
||||
-F "commit=$TRAVIS_COMMIT" \
|
||||
-F "date=`git log --format='%ct' -1`" \
|
||||
-F "pull_request=$TRAVIS_PULL_REQUEST" \
|
||||
@@ -67,12 +71,40 @@ script:
|
||||
fi
|
||||
elif [ "$TEST_TYPE" = test ]; then
|
||||
set -e
|
||||
./node_modules/.bin/grunt jest:normal
|
||||
./node_modules/.bin/grunt jest:coverage
|
||||
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
|
||||
|
||||
echo 'Testing in server-render (HTML generation) mode...'
|
||||
printf '\nmodule.exports.useCreateElement = false;\n' \
|
||||
>> src/renderers/dom/shared/ReactDOMFeatureFlags.js
|
||||
./node_modules/.bin/grunt jest:normal
|
||||
git checkout -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
|
||||
|
||||
echo 'Testing in fiber mode...'
|
||||
printf '\nmodule.exports.useFiber = true;\n' \
|
||||
>> src/renderers/dom/shared/ReactDOMFeatureFlags.js
|
||||
FIBER_TESTS=`\
|
||||
NODE_ENV=test node node_modules/jest/bin/jest --json | \
|
||||
node -e "\
|
||||
var data = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8')); \
|
||||
console.log(data.numPassedTests + '/' + data.numTotalTests)\
|
||||
"\
|
||||
`
|
||||
git checkout -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
|
||||
node scripts/facts-tracker/index.js \
|
||||
"fiber-tests" "$FIBER_TESTS"
|
||||
|
||||
./node_modules/.bin/gulp react:extract-errors
|
||||
elif [ "$TEST_TYPE" = flow ]; then
|
||||
set -e
|
||||
./node_modules/.bin/grunt flow
|
||||
|
||||
ALL_FILES=`find src -name '*.js' | grep -v umd/ | grep -v __tests__ | grep -v __mocks__`
|
||||
COUNT_ALL_FILES=`echo "$ALL_FILES" | wc -l`
|
||||
COUNT_WITH_FLOW=`grep '@flow' $ALL_FILES | perl -pe 's/:.+//' | wc -l`
|
||||
node scripts/facts-tracker/index.js \
|
||||
"flow-files" "$COUNT_WITH_FLOW/$COUNT_ALL_FILES"
|
||||
|
||||
else
|
||||
./node_modules/.bin/grunt $TEST_TYPE
|
||||
fi
|
||||
@@ -81,6 +113,7 @@ env:
|
||||
- TEST_TYPE=build
|
||||
- TEST_TYPE=test
|
||||
- TEST_TYPE=lint
|
||||
- TEST_TYPE=flow
|
||||
- TEST_TYPE=build_website
|
||||
global:
|
||||
# SERVER
|
||||
|
||||
444
CHANGELOG.md
444
CHANGELOG.md
@@ -1,3 +1,433 @@
|
||||
## 15.6.0 (June 13, 2017)
|
||||
|
||||
### React
|
||||
|
||||
* Downgrade deprecation warnings to use `console.warn` instead of `console.error`. ([@flarnie](https://github.com/flarnie) in [#9753](https://github.com/facebook/react/pull/9753))
|
||||
* Add a deprecation warning for `React.createClass`. Points users to `create-react-class` instead. ([@flarnie](https://github.com/flarnie) in [#9771](https://github.com/facebook/react/pull/9771))
|
||||
* Add deprecation warnings and separate module for `React.DOM` factory helpers. ([@nhunzaker](https://github.com/nhunzaker) in [#8356](https://github.com/facebook/react/pull/8356))
|
||||
* Warn for deprecation of `React.createMixin` helper, which was never used. ([@aweary](https://github.com/aweary) in [#8853](https://github.com/facebook/react/pull/8853))
|
||||
|
||||
### React DOM
|
||||
|
||||
* Add support for CSS variables in `style` attribute. ([@aweary](https://github.com/aweary) in [#9302](https://github.com/facebook/react/pull/9302))
|
||||
* Add support for CSS Grid style properties. ([@ericsakmar](https://github.com/ericsakmar) in [#9185](https://github.com/facebook/react/pull/9185))
|
||||
* Fix bug where inputs mutated value on type conversion. ([@nhunzaker](https://github.com/mhunzaker) in [#9806](https://github.com/facebook/react/pull/9806))
|
||||
* Fix issues with `onChange` not firing properly for some inputs. ([@jquense](https://github.com/jquense) in [#8575](https://github.com/facebook/react/pull/8575))
|
||||
* Fix bug where controlled number input mistakenly allowed period. ([@nhunzaker](https://github.com/nhunzaker) in [#9584](https://github.com/facebook/react/pull/9584))
|
||||
* Fix bug where performance entries were being cleared. ([@chrisui](https://github.com/chrisui) in [#9451](https://github.com/facebook/react/pull/9451))
|
||||
|
||||
### React Addons
|
||||
|
||||
* Fix AMD support for addons depending on `react`. ([@flarnie](https://github.com/flarnie) in [#9919](https://github.com/facebook/react/issues/9919))
|
||||
* Fix `isMounted()` to return `true` in `componentWillUnmount`. ([@mridgway](https://github.com/mridgway) in [#9638](https://github.com/facebook/react/issues/9638))
|
||||
* Fix `react-addons-update` to not depend on native `Object.assign`. ([@gaearon](https://github.com/gaearon) in [#9937](https://github.com/facebook/react/pull/9937))
|
||||
* Remove broken Google Closure Compiler annotation from `create-react-class`. ([@gaearon](https://github.com/gaearon) in [#9933](https://github.com/facebook/react/pull/9933))
|
||||
* Remove unnecessary dependency from `react-linked-input`. ([@gaearon](https://github.com/gaearon) in [#9766](https://github.com/facebook/react/pull/9766))
|
||||
* Point `react-addons-(css-)transition-group` to the new package. ([@gaearon](https://github.com/gaearon) in [#9937](https://github.com/facebook/react/pull/9937))
|
||||
|
||||
## 15.5.4 (April 11, 2017)
|
||||
|
||||
### React Addons
|
||||
* **Critical Bugfix:** Update the version of `prop-types` to fix critical bug. ([@gaearon](https://github.com/gaearon) in [545c87f](https://github.com/facebook/react/commit/545c87fdc348f82eb0c3830bef715ed180785390))
|
||||
* Fix `react-addons-create-fragment` package to include `loose-envify` transform for Browserify users. ([@mridgway](https://github.com/mridgway) in [#9642](https://github.com/facebook/react/pull/9642))
|
||||
|
||||
### React Test Renderer
|
||||
* Fix compatibility with Enzyme by exposing `batchedUpdates` on shallow renderer. ([@gaearon](https://github.com/gaearon) in [9382](https://github.com/facebook/react/commit/69933e25c37cf5453a9ef132177241203ee8d2fd))
|
||||
|
||||
## 15.5.3 (April 7, 2017)
|
||||
|
||||
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
|
||||
|
||||
### React Addons
|
||||
* Fix `react-addons-create-fragment` package to export correct thing. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
|
||||
* Fix `create-react-class` package to include `loose-envify` transform for Browserify users. ([@mridgway](https://github.com/mridgway) in [#9642](https://github.com/facebook/react/pull/9642))
|
||||
|
||||
## 15.5.2 (April 7, 2017)
|
||||
|
||||
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
|
||||
|
||||
### React Addons
|
||||
* Fix the production single-file builds to not include the development code. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
|
||||
* Apply better minification to production single-file builds. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
|
||||
* Add missing and remove unnecessary dependencies to packages. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
|
||||
|
||||
## 15.5.1 (April 7, 2017)
|
||||
|
||||
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
|
||||
|
||||
### React
|
||||
* Fix erroneous PropTypes access warning. ([@acdlite](https://github.com/acdlite) in ([ec97ebb](https://github.com/facebook/react/commit/ec97ebbe7f15b58ae2f1323df39d06f119873344))
|
||||
|
||||
## 15.5.0 (April 7, 2017)
|
||||
|
||||
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
|
||||
|
||||
### React
|
||||
* <s>Added a deprecation warning for `React.createClass`. Points users to create-react-class instead. ([@acdlite](https://github.com/acdlite) in [#d9a4fa4](https://github.com/facebook/react/commit/d9a4fa4f51c6da895e1655f32255cf72c0fe620e))</s>
|
||||
* Added a deprecation warning for `React.PropTypes`. Points users to prop-types instead. ([@acdlite](https://github.com/acdlite) in [#043845c](https://github.com/facebook/react/commit/043845ce75ea0812286bbbd9d34994bb7e01eb28))
|
||||
* Fixed an issue when using `ReactDOM` together with `ReactDOMServer`. ([@wacii](https://github.com/wacii) in [#9005](https://github.com/facebook/react/pull/9005))
|
||||
* Fixed issue with Closure Compiler. ([@anmonteiro](https://github.com/anmonteiro) in [#8895](https://github.com/facebook/react/pull/8895))
|
||||
* Another fix for Closure Compiler. ([@Shastel](https://github.com/Shastel) in [#8882](https://github.com/facebook/react/pull/8882))
|
||||
* Added component stack info to invalid element type warning. ([@n3tr](https://github.com/n3tr) in [#8495](https://github.com/facebook/react/pull/8495))
|
||||
|
||||
### React DOM
|
||||
* Fixed Chrome bug when backspacing in number inputs. ([@nhunzaker](https://github.com/nhunzaker) in [#7359](https://github.com/facebook/react/pull/7359))
|
||||
* Added `react-dom/test-utils`, which exports the React Test Utils. ([@bvaughn](https://github.com/bvaughn))
|
||||
|
||||
### React Test Renderer
|
||||
* Fixed bug where `componentWillUnmount` was not called for children. ([@gre](https://github.com/gre) in [#8512](https://github.com/facebook/react/pull/8512))
|
||||
* Added `react-test-renderer/shallow`, which exports the shallow renderer. ([@bvaughn](https://github.com/bvaughn))
|
||||
|
||||
### React Addons
|
||||
* Last release for addons; they will no longer be actively maintained.
|
||||
* Removed `peerDependencies` so that addons continue to work indefinitely. ([@acdlite](https://github.com/acdlite) and [@bvaughn](https://github.com/bvaughn) in [8a06cd7](https://github.com/facebook/react/commit/8a06cd7a786822fce229197cac8125a551e8abfa) and [67a8db3](https://github.com/facebook/react/commit/67a8db3650d724a51e70be130e9008806402678a))
|
||||
* Updated to remove references to `React.createClass` and `React.PropTypes` ([@acdlite](https://github.com/acdlite) in [12a96b9](https://github.com/facebook/react/commit/12a96b94823d6b6de6b1ac13bd576864abd50175))
|
||||
* `react-addons-test-utils` is deprecated. Use `react-dom/test-utils` and `react-test-renderer/shallow` instead. ([@bvaughn](https://github.com/bvaughn))
|
||||
|
||||
## 15.4.2 (January 6, 2017)
|
||||
|
||||
### React
|
||||
* Fixed build issues with the Brunch bundler. ([@gaearon](https://github.com/gaearon) in [#8686](https://github.com/facebook/react/pull/8686))
|
||||
* Improved error messages for invalid element types. ([@spicyj](https://github.com/spicyj) in [#8612](https://github.com/facebook/react/pull/8612))
|
||||
* Removed a warning about `getInitialState` when `this.state` is set. ([@bvaughn](https://github.com/bvaughn) in [#8594](https://github.com/facebook/react/pull/8594))
|
||||
* Removed some dead code. ([@diegomura](https://github.com/diegomura) in [#8050](https://github.com/facebook/react/pull/8050), [@dfrownfelter](https://github.com/dfrownfelter) in [#8597](https://github.com/facebook/react/pull/8597))
|
||||
|
||||
### React DOM
|
||||
* Fixed a decimal point issue on uncontrolled number inputs. ([@nhunzaker](https://github.com/nhunzaker) in [#7750](https://github.com/facebook/react/pull/7750))
|
||||
* Fixed rendering of textarea placeholder in IE11. ([@aweary](https://github.com/aweary) in [#8020](https://github.com/facebook/react/pull/8020))
|
||||
* Worked around a script engine bug in IE9. ([@eoin](https://github.com/eoin) in [#8018](https://github.com/facebook/react/pull/8018))
|
||||
|
||||
### React Addons
|
||||
* Fixed build issues in RequireJS and SystemJS environments. ([@gaearon](https://github.com/gaearon) in [#8686](https://github.com/facebook/react/pull/8686))
|
||||
* Added missing package dependencies. ([@kweiberth](https://github.com/kweiberth) in [#8467](https://github.com/facebook/react/pull/8467))
|
||||
|
||||
## 15.4.1 (November 22, 2016)
|
||||
|
||||
### React
|
||||
* Restructure variable assignment to work around a Rollup bug ([@gaearon](https://github.com/gaearon) in [#8384](https://github.com/facebook/react/pull/8384))
|
||||
|
||||
### React DOM
|
||||
* Fixed event handling on disabled button elements ([@spicyj](https://github.com/spicyj) in [#8387](https://github.com/facebook/react/pull/8387))
|
||||
* Fixed compatibility of browser build with AMD environments ([@zpao](https://github.com/zpao) in [#8374](https://github.com/facebook/react/pull/8374))
|
||||
|
||||
## 15.4.0 (November 16, 2016)
|
||||
|
||||
### React
|
||||
* React package and browser build no longer "secretly" includes React DOM. ([@sebmarkbage](https://github.com/sebmarkbage) in [#7164](https://github.com/facebook/react/pull/7164) and [#7168](https://github.com/facebook/react/pull/7168))
|
||||
* Required PropTypes now fail with specific messages for null and undefined. ([@chenglou](https://github.com/chenglou) in [#7291](https://github.com/facebook/react/pull/7291))
|
||||
* Improved development performance by freezing children instead of copying. ([@keyanzhang](https://github.com/keyanzhang) in [#7455](https://github.com/facebook/react/pull/7455))
|
||||
|
||||
### React DOM
|
||||
* Fixed occasional test failures when React DOM is used together with shallow renderer. ([@goatslacker](https://github.com/goatslacker) in [#8097](https://github.com/facebook/react/pull/8097))
|
||||
* Added a warning for invalid `aria-` attributes. ([@jessebeach](https://github.com/jessebeach) in [#7744](https://github.com/facebook/react/pull/7744))
|
||||
* Added a warning for using `autofocus` rather than `autoFocus`. ([@hkal](https://github.com/hkal) in [#7694](https://github.com/facebook/react/pull/7694))
|
||||
* Removed an unnecessary warning about polyfilling `String.prototype.split`. ([@nhunzaker](https://github.com/nhunzaker) in [#7629](https://github.com/facebook/react/pull/7629))
|
||||
* Clarified the warning about not calling PropTypes manually. ([@jedwards1211](https://github.com/jedwards1211) in [#7777](https://github.com/facebook/react/pull/7777))
|
||||
* The unstable `batchedUpdates` API now passes the wrapped function's return value through. ([@bgnorlov](https://github.com/bgnorlov) in [#7444](https://github.com/facebook/react/pull/7444))
|
||||
* Fixed a bug with updating text in IE 8. ([@mnpenner](https://github.com/mnpenner) in [#7832](https://github.com/facebook/react/pull/7832))
|
||||
|
||||
### React Perf
|
||||
* When ReactPerf is started, you can now view the relative time spent in components as a chart in Chrome Timeline. ([@gaearon](https://github.com/gaearon) in [#7549](https://github.com/facebook/react/pull/7549))
|
||||
|
||||
### React Test Utils
|
||||
* If you call `Simulate.click()` on a `<input disabled onClick={foo} />` then `foo` will get called whereas it didn't before. ([@nhunzaker](https://github.com/nhunzaker) in [#7642](https://github.com/facebook/react/pull/7642))
|
||||
|
||||
### React Test Renderer
|
||||
* Due to packaging changes, it no longer crashes when imported together with React DOM in the same file. ([@sebmarkbage](https://github.com/sebmarkbage) in [#7164](https://github.com/facebook/react/pull/7164) and [#7168](https://github.com/facebook/react/pull/7168))
|
||||
* `ReactTestRenderer.create()` now accepts `{createNodeMock: element => mock}` as an optional argument so you can mock refs with snapshot testing. ([@Aweary](https://github.com/Aweary) in [#7649](https://github.com/facebook/react/pull/7649), [#8261](https://github.com/facebook/react/pull/8261))
|
||||
|
||||
|
||||
## 15.3.2 (September 19, 2016)
|
||||
|
||||
### React
|
||||
- Remove plain object warning from React.createElement & React.cloneElement. ([@spudly](https://github.com/spudly) in [#7724](https://github.com/facebook/react/pull/7724))
|
||||
|
||||
### React DOM
|
||||
- Add `playsInline` to supported HTML attributes. ([@reaperhulk](https://github.com/reaperhulk) in [#7519](https://github.com/facebook/react/pull/7519))
|
||||
- Add `as` to supported HTML attributes. ([@kevinslin](https://github.com/kevinslin) in [#7582](https://github.com/facebook/react/pull/7582))
|
||||
- Improve DOM nesting validation warning about whitespace. ([@spicyj](https://github.com/spicyj) in [#7515](https://github.com/facebook/react/pull/7515))
|
||||
- Avoid "Member not found" exception in IE10 when calling `preventDefault()` in Synthetic Events. ([@g-palmer](https://github.com/g-palmer) in [#7411](https://github.com/facebook/react/pull/7411))
|
||||
- Fix memory leak in `onSelect` implementation. ([@AgtLucas](https://github.com/AgtLucas) in [#7533](https://github.com/facebook/react/pull/7533))
|
||||
- Improve robustness of `document.documentMode` checks to handle Google Tag Manager. ([@SchleyB](https://github.com/SchleyB) in [#7594](https://github.com/facebook/react/pull/7594))
|
||||
- Add more cases to controlled inputs warning. ([@marcin-mazurek](https://github.com/marcin-mazurek) in [#7544](https://github.com/facebook/react/pull/7544))
|
||||
- Handle case of popup blockers overriding `document.createEvent`. ([@Andarist](https://github.com/Andarist) in [#7621](https://github.com/facebook/react/pull/7621))
|
||||
- Fix issue with `dangerouslySetInnerHTML` and SVG in Internet Explorer. ([@zpao](https://github.com/zpao) in [#7618](https://github.com/facebook/react/pull/7618))
|
||||
- Improve handling of Japanese IME on Internet Explorer. ([@msmania](https://github.com/msmania) in [#7107](https://github.com/facebook/react/pull/7107))
|
||||
|
||||
### React Test Renderer
|
||||
- Support error boundaries. ([@millermedeiros](https://github.com/millermedeiros) in [#7558](https://github.com/facebook/react/pull/7558), [#7569](https://github.com/facebook/react/pull/7569), [#7619](https://github.com/facebook/react/pull/7619))
|
||||
- Skip null ref warning. ([@Aweary](https://github.com/Aweary) in [#7658](https://github.com/facebook/react/pull/7658))
|
||||
|
||||
### React Perf Add-on
|
||||
- Ensure lifecycle timers are stopped on errors. ([@gaearon](https://github.com/gaearon) in [#7548](https://github.com/facebook/react/pull/7548))
|
||||
|
||||
|
||||
## 15.3.1 (August 19, 2016)
|
||||
|
||||
### React
|
||||
|
||||
- Improve performance of development builds in various ways. ([@gaearon](https://github.com/gaearon) in [#7461](https://github.com/facebook/react/pull/7461), [#7463](https://github.com/facebook/react/pull/7463), [#7483](https://github.com/facebook/react/pull/7483), [#7488](https://github.com/facebook/react/pull/7488), [#7491](https://github.com/facebook/react/pull/7491), [#7510](https://github.com/facebook/react/pull/7510))
|
||||
- Cleanup internal hooks to improve performance of development builds. ([@gaearon](https://github.com/gaearon) in [#7464](https://github.com/facebook/react/pull/7464), [#7472](https://github.com/facebook/react/pull/7472), [#7481](https://github.com/facebook/react/pull/7481), [#7496](https://github.com/facebook/react/pull/7496))
|
||||
- Upgrade fbjs to pick up another performance improvement from [@gaearon](https://github.com/gaearon) for development builds. ([@zpao](https://github.com/zpao) in [#7532](https://github.com/facebook/react/pull/7532))
|
||||
- Improve startup time of React in Node. ([@zertosh](https://github.com/zertosh) in [#7493](https://github.com/facebook/react/pull/7493))
|
||||
- Improve error message of `React.Children.only`. ([@spicyj](https://github.com/spicyj) in [#7514](https://github.com/facebook/react/pull/7514))
|
||||
|
||||
### React DOM
|
||||
- Avoid `<input>` validation warning from browsers when changing `type`. ([@nhunzaker](https://github.com/nhunzaker) in [#7333](https://github.com/facebook/react/pull/7333))
|
||||
- Avoid "Member not found" exception in IE10 when calling `stopPropagation()` in Synthetic Events. ([@nhunzaker](https://github.com/nhunzaker) in [#7343](https://github.com/facebook/react/pull/7343))
|
||||
- Fix issue resulting in inability to update some `<input>` elements in mobile browsers. ([@keyanzhang](https://github.com/keyanzhang) in [#7397](https://github.com/facebook/react/pull/7397))
|
||||
- Fix memory leak in server rendering. ([@keyanzhang](https://github.com/keyanzhang) in [#7410](https://github.com/facebook/react/pull/7410))
|
||||
- Fix issue resulting in `<input type="range">` values not updating when changing `min` or `max`. ([@troydemonbreun](https://github.com/troydemonbreun) in [#7486](https://github.com/facebook/react/pull/7486))
|
||||
- Add new warning for rare case of attempting to unmount a container owned by a different copy of React. ([@ventuno](https://github.com/ventuno) in [#7456](https://github.com/facebook/react/pull/7456))
|
||||
|
||||
### React Test Renderer
|
||||
- Fix ReactTestInstance::toJSON() with empty top-level components. ([@Morhaus](https://github.com/Morhaus) in [#7523](https://github.com/facebook/react/pull/7523))
|
||||
|
||||
### React Native Renderer
|
||||
- Change `trackedTouchCount` invariant into a console.error for better reliability. ([@yungsters](https://github.com/yungsters) in [#7400](https://github.com/facebook/react/pull/7400))
|
||||
|
||||
|
||||
## 15.3.0 (July 29, 2016)
|
||||
|
||||
### React
|
||||
- Add `React.PureComponent` - a new base class to extend, replacing `react-addons-pure-render-mixin` now that mixins don't work with ES2015 classes. ([@spicyj](https://github.com/spicyj) in [#7195](https://github.com/facebook/react/pull/7195))
|
||||
- Add new warning when modifying `this.props.children`. ([@jimfb](https://github.com/jimfb) in [#7001](https://github.com/facebook/react/pull/7001))
|
||||
- Fixed issue with ref resolution order. ([@gaearon](https://github.com/gaearon) in [#7101](https://github.com/facebook/react/pull/7101))
|
||||
- Warn when mixin is undefined. ([@swaroopsm](https://github.com/swaroopsm) in [#6158](https://github.com/facebook/react/pull/6158))
|
||||
- Downgrade "unexpected batch number" invariant to a warning. ([@spicyj](https://github.com/spicyj) in [#7133](https://github.com/facebook/react/pull/7133))
|
||||
- Validate arguments to `oneOf` and `oneOfType` PropTypes sooner. ([@troydemonbreun](https://github.com/troydemonbreun) in [#6316](https://github.com/facebook/react/pull/6316))
|
||||
- Warn when calling PropTypes directly. ([@Aweary](https://github.com/Aweary) in [#7132](https://github.com/facebook/react/pull/7132), [#7194](https://github.com/facebook/react/pull/7194))
|
||||
- Improve warning when using Maps as children. ([@keyanzhang](https://github.com/keyanzhang) in [#7260](https://github.com/facebook/react/pull/7260))
|
||||
- Add additional type information to the `PropTypes.element` warning. ([@alexzherdev](https://github.com/alexzherdev) in [#7319](https://github.com/facebook/react/pull/7319))
|
||||
- Improve component identification in no-op `setState` warning. ([@keyanzhang](https://github.com/keyanzhang) in [#7326](https://github.com/facebook/react/pull/7326))
|
||||
|
||||
### React DOM
|
||||
- Fix issue with nested server rendering. ([@Aweary](https://github.com/Aweary) in [#7033](https://github.com/facebook/react/pull/7033))
|
||||
- Add `xmlns`, `xmlnsXlink` to supported SVG attributes. ([@salzhrani](https://github.com/salzhrani) in [#6471](https://github.com/facebook/react/pull/6471))
|
||||
- Add `referrerPolicy` to supported HTML attributes. ([@Aweary](https://github.com/Aweary) in [#7274](https://github.com/facebook/react/pull/7274))
|
||||
- Fix issue resulting in `<input type="range">` initial value being rounded. ([@troydemonbreun](https://github.com/troydemonbreun) in [#7251](https://github.com/facebook/react/pull/7251))
|
||||
|
||||
### React Test Renderer
|
||||
- Initial public release of package allowing more focused testing. Install with `npm install react-test-renderer`. ([@spicyj](https://github.com/spicyj) in [#6944](https://github.com/facebook/react/pull/6944), [#7258](https://github.com/facebook/react/pull/7258), [@iamdustan](https://github.com/iamdustan) in [#7362](https://github.com/facebook/react/pull/7362))
|
||||
|
||||
### React Perf Add-on
|
||||
- Fix issue resulting in excessive warnings when encountering an internal measurement error. ([@sassanh](https://github.com/sassanh) in [#7299](https://github.com/facebook/react/pull/7299))
|
||||
|
||||
### React TestUtils Add-on
|
||||
- Implement `type` property on for events created via `TestUtils.Simulate.*`. ([@yaycmyk](https://github.com/yaycmyk) in [#6154](https://github.com/facebook/react/pull/6154))
|
||||
- Fix crash when running TestUtils with the production build of React. ([@gaearon](https://github.com/gaearon) in [#7246](https://github.com/facebook/react/pull/7246))
|
||||
|
||||
|
||||
## 15.2.1 (July 8, 2016)
|
||||
|
||||
### React
|
||||
- Fix errant warning about missing React element. ([@gaearon](https://github.com/gaearon) in [#7193](https://github.com/facebook/react/pull/7193))
|
||||
- Better removal of dev-only code, leading to a small reduction in the minified production bundle size. ([@gaearon](https://github.com/gaearon) in [#7188](https://github.com/facebook/react/pull/7188), [#7189](https://github.com/facebook/react/pull/7189))
|
||||
|
||||
### React DOM
|
||||
- Add stack trace to null input value warning. ([@jimfb](https://github.com/jimfb) in [#7040](https://github.com/facebook/react/pull/7040))
|
||||
- Fix webcomponents example. ([@jalexanderfox](https://github.com/jalexanderfox) in [#7057](https://github.com/facebook/react/pull/7057))
|
||||
- Fix `unstable_renderSubtreeIntoContainer` so that context properly updates when linked to state. ([@gaearon](https://github.com/gaearon) in [#7125](https://github.com/facebook/react/pull/7125))
|
||||
- Improve invariant wording for void elements. ([@starkch](https://github.com/starkch) in [#7066](https://github.com/facebook/react/pull/7066))
|
||||
- Ensure no errors are thrown due to event handlers in server rendering. ([@rricard](https://github.com/rricard) in [#7127](https://github.com/facebook/react/pull/7127))
|
||||
- Fix regression resulting in `value`-less submit and reset inputs removing the browser-default text. ([@zpao](https://github.com/zpao) in [#7197](https://github.com/facebook/react/pull/7197))
|
||||
- Fix regression resulting in empty `name` attribute being added to inputs when not provided. ([@okonet](https://github.com/okonet) in [#7199](https://github.com/facebook/react/pull/7199))
|
||||
- Fix issue with nested server rendering. ([@Aweary](https://github.com/Aweary) in [#7033](https://github.com/facebook/react/pull/7033))
|
||||
|
||||
### React Perf Add-on
|
||||
- Make `ReactPerf.start()` work properly during lifecycle methods. ([@gaearon](https://github.com/gaearon) in [#7208](https://github.com/facebook/react/pull/7208)).
|
||||
|
||||
### React CSSTransitionGroup Add-on
|
||||
- Fix issue resulting in spurious unknown property warnings. ([@batusai513](https://github.com/batusai513) in [#7165](https://github.com/facebook/react/pull/7165))
|
||||
|
||||
### React Native Renderer
|
||||
- Improve error handling in cross-platform touch event handling. ([@yungsters](https://github.com/yungsters) in [#7143](https://github.com/facebook/react/pull/7143))
|
||||
|
||||
|
||||
## 15.2.0 (July 1, 2016)
|
||||
|
||||
### React
|
||||
- Add error codes to production invariants, with links to the view the full error text. ([@keyanzhang](https://github.com/keyanzhang) in [#6948](https://github.com/facebook/react/pull/6948))
|
||||
- Include component stack information in PropType validation warnings. ([@troydemonbreun](https://github.com/troydemonbreun) in [#6398](https://github.com/facebook/react/pull/6398), [@spicyj](https://github.com/spicyj) in [#6771](https://github.com/facebook/react/pull/6771))
|
||||
- Include component stack information in key warnings. ([@keyanzhang](https://github.com/keyanzhang) in [#6799](https://github.com/facebook/react/pull/6799))
|
||||
- Stop validating props at mount time, only validate at element creation. ([@keyanzhang](https://github.com/keyanzhang) in [#6824](https://github.com/facebook/react/pull/6824))
|
||||
- New invariant providing actionable error in missing instance case. ([@yungsters](https://github.com/yungsters) in [#6990](https://github.com/facebook/react/pull/6990))
|
||||
- Add `React.PropTypes.symbol` to support ES2015 Symbols as props. ([@puradox](https://github.com/puradox) in [#6377](https://github.com/facebook/react/pull/6377))
|
||||
- Fix incorrect coercion of ref or key that are undefined in development ([@gaearon](https://github.com/gaearon) in [#6880](https://github.com/facebook/react/pull/6880))
|
||||
- Fix a false positive when passing other element’s props to cloneElement ([@ericmatthys](https://github.com/ericmatthys) in [#6268](https://github.com/facebook/react/pull/6268))
|
||||
- Warn if you attempt to define `childContextTypes` on a functional component ([@Aweary](https://github.com/Aweary) in [#6933](https://github.com/facebook/react/pull/6933))
|
||||
|
||||
### React DOM
|
||||
- Add warning for unknown properties on DOM elements. ([@jimfb](https://github.com/jimfb) in [#6800](https://github.com/facebook/react/pull/6800), [@gm758](https://github.com/gm758) in [#7152](https://github.com/facebook/react/pull/7152))
|
||||
- Properly remove attributes from custom elements. ([@grassator](https://github.com/grassator) in [#6748](https://github.com/facebook/react/pull/6748))
|
||||
- Fix invalid unicode escape in attribute name regular expression. ([@nbjahan](https://github.com/nbjahan) in [#6772](https://github.com/facebook/react/pull/6772))
|
||||
- Add `onLoad` handling to `<link>` element. ([@roderickhsiao](https://github.com/roderickhsiao) in [#6815](https://github.com/facebook/react/pull/6815))
|
||||
- Add `onError` handling to `<source>` element. ([@wadahiro](https://github.com/wadahiro) in [#6941](https://github.com/facebook/react/pull/6941))
|
||||
- Handle `value` and `defaultValue` more accurately in the DOM. ([@jimfb](https://github.com/jimfb) in [#6406](https://github.com/facebook/react/pull/6406))
|
||||
- Fix events issue in environments with mutated `Object.prototype`. ([@Weizenlol](https://github.com/Weizenlol) in [#6886](https://github.com/facebook/react/pull/6886))
|
||||
- Fix issue where `is="null"` ended up in the DOM in Firefox. ([@darobin](https://github.com/darobin) in [#6896](https://github.com/facebook/react/pull/6896))
|
||||
- Improved performance of text escaping by using [escape-html](https://github.com/component/escape-html). ([@aickin](https://github.com/aickin) in [#6862](https://github.com/facebook/react/pull/6862))
|
||||
- Fix issue with `dangerouslySetInnerHTML` and SVG in Internet Explorer. ([@joshhunt](https://github.com/joshhunt) in [#6982](https://github.com/facebook/react/pull/6982))
|
||||
- Fix issue with `<textarea>` placeholders. ([@jimfb](https://github.com/jimfb) in [#7002](https://github.com/facebook/react/pull/7002))
|
||||
- Fix controlled vs uncontrolled detection of `<input type="radio"/>`. ([@jimfb](https://github.com/jimfb) in [#7003](https://github.com/facebook/react/pull/7003))
|
||||
- Improve performance of updating text content. ([@trueadm](https://github.com/trueadm) in [#7005](https://github.com/facebook/react/pull/7005))
|
||||
- Ensure controlled `<select>` components behave the same on initial render as they do on updates. ([@yiminghe](https://github.com/yiminghe) in [#5362](https://github.com/facebook/react/pull/5362))
|
||||
|
||||
### React Perf Add-on
|
||||
- Add `isRunning()` API. ([@nfcampos](https://github.com/nfcampos) in [#6763](https://github.com/facebook/react/pull/6763))
|
||||
- Improve accuracy of lifecycle hook timing. ([@gaearon](https://github.com/gaearon) in [#6858](https://github.com/facebook/react/pull/6858))
|
||||
- Fix internal errors when using ReactPerf with portal components. ([@gaearon](https://github.com/gaearon) in [#6860](https://github.com/facebook/react/pull/6860))
|
||||
- Fix performance regression. ([@spicyj](https://github.com/spicyj) in [#6770](https://github.com/facebook/react/pull/6770))
|
||||
- Add warning that ReactPerf is not enabled in production. ([@sashashakun](https://github.com/sashashakun) in [#6884](https://github.com/facebook/react/pull/6884))
|
||||
|
||||
### React CSSTransitionGroup Add-on
|
||||
- Fix timing issue with `null` node. ([@keyanzhang](https://github.com/keyanzhang) in [#6958](https://github.com/facebook/react/pull/6958))
|
||||
|
||||
### React Native Renderer
|
||||
- Dependencies on React Native modules use CommonJS requires instead of providesModule. ([@davidaurelio](https://github.com/davidaurelio) in [#6715](https://github.com/facebook/react/pull/6715))
|
||||
|
||||
|
||||
## 15.1.0 (May 20, 2016)
|
||||
|
||||
### React
|
||||
- Ensure we're using the latest `object-assign`, which has protection against a non-spec-compliant native `Object.assign`. ([@zpao](https://github.com/zpao) in [#6681](https://github.com/facebook/react/pull/6681))
|
||||
- Add a new warning to communicate that `props` objects passed to `createElement` must be plain objects. ([@richardscarrott](https://github.com/richardscarrott) in [#6134](https://github.com/facebook/react/pull/6134))
|
||||
- Fix a batching bug resulting in some lifecycle methods incorrectly being called multiple times. ([@spicyj](https://github.com/spicyj) in [#6650](https://github.com/facebook/react/pull/6650))
|
||||
|
||||
### React DOM
|
||||
- Fix regression in custom elements support. ([@jscissr](https://github.com/jscissr) in [#6570](https://github.com/facebook/react/pull/6570))
|
||||
- Stop incorrectly warning about using `onScroll` event handler with server rendering. ([@Aweary](https://github.com/Aweary) in [#6678](https://github.com/facebook/react/pull/6678))
|
||||
- Fix grammar in the controlled input warning. ([@jakeboone02](https://github.com/jakeboone02) in [#6657](https://github.com/facebook/react/pull/6657))
|
||||
- Fix issue preventing `<object>` nodes from being able to read `<param>` nodes in IE. ([@syranide](https://github.com/syranide) in [#6691](https://github.com/facebook/react/pull/6691))
|
||||
- Fix issue resulting in crash when using experimental error boundaries with server rendering. ([@jimfb](https://github.com/jimfb) in [#6694](https://github.com/facebook/react/pull/6694))
|
||||
- Add additional information to the controlled input warning. ([@borisyankov](https://github.com/borisyankov) in [#6341](https://github.com/facebook/react/pull/6341))
|
||||
|
||||
### React Perf Add-on
|
||||
- Completely rewritten to collect data more accurately and to be easier to maintain. ([@gaearon](https://github.com/gaearon) in [#6647](https://github.com/facebook/react/pull/6647), [#6046](https://github.com/facebook/react/pull/6046))
|
||||
|
||||
### React Native Renderer
|
||||
- Remove some special cases for platform specific branching. ([@sebmarkbage](https://github.com/sebmarkbage) in [#6660](https://github.com/facebook/react/pull/6660))
|
||||
- Remove use of `merge` utility. ([@sebmarkbage](https://github.com/sebmarkbage) in [#6634](https://github.com/facebook/react/pull/6634))
|
||||
- Renamed some modules to better indicate usage ([@javache](https://github.com/javache) in [#6643](https://github.com/facebook/react/pull/6643))
|
||||
|
||||
|
||||
## 15.0.2 (April 29, 2016)
|
||||
|
||||
### React
|
||||
- Removed extraneous files from npm package. ([@gaearon](https://github.com/gaearon) in [#6388](https://github.com/facebook/react/pull/6388))
|
||||
- Ensure `componentWillUnmount` is only called once. ([@jimfb](https://github.com/jimfb) in [#6613](https://github.com/facebook/react/pull/6613))
|
||||
|
||||
### ReactDOM
|
||||
- Fixed bug resulting in disabled buttons responding to mouse events in IE. ([@nhunzaker](https://github.com/nhunzaker) in [#6215](https://github.com/facebook/react/pull/6215))
|
||||
- Ensure `<option>`s are correctly selected when inside `<optgroup>`. ([@trevorsmith](https://github.com/trevorsmith) in [#6442](https://github.com/facebook/react/pull/6442))
|
||||
- Restore support for rendering into a shadow root. ([@Wildhoney](https://github.com/Wildhoney) in [#6462](https://github.com/facebook/react/pull/6462))
|
||||
- Ensure nested `<body>` elements are caught when warning for invalid markup. ([@keyanzhang](https://github.com/keyanzhang) in [#6469](https://github.com/facebook/react/pull/6469))
|
||||
- Improve warning when encountering multiple elements with the same key. ([@hkal](https://github.com/hkal) in [#6500](https://github.com/facebook/react/pull/6500))
|
||||
|
||||
### React TestUtils Add-on
|
||||
- Ensure that functional components do not have an owner. ([@gaearon](https://github.com/gaearon) in [#6362](https://github.com/facebook/react/pull/6362))
|
||||
- Handle invalid arguments to `scryRenderedDOMComponentsWithClass` better. ([@ipeters90](https://github.com/ipeters90) in [#6529](https://github.com/facebook/react/pull/6529))
|
||||
|
||||
### React Perf Add-on
|
||||
- Ignore DOM operations that occur outside the batch operation. ([@gaearon](https://github.com/gaearon) in [#6516](https://github.com/facebook/react/pull/6516))
|
||||
|
||||
### React Native Renderer
|
||||
- These files are now shipped inside the React npm package. They have no impact on React core or ReactDOM.
|
||||
|
||||
|
||||
## 15.0.1 (April 8, 2016)
|
||||
|
||||
### React
|
||||
- Restore `React.__spread` API to unbreak code compiled with some tools making use of this undocumented API. It is now officially deprecated. ([@zpao](https://github.com/zpao) in [#6444](https://github.com/facebook/react/pull/6444))
|
||||
|
||||
### ReactDOM
|
||||
- Fixed issue resulting in loss of cursor position in controlled inputs. ([@spicyj](https://github.com/spicyj) in [#6449](https://github.com/facebook/react/pull/6449))
|
||||
|
||||
|
||||
## 15.0.0 (April 7, 2016)
|
||||
|
||||
### Major changes
|
||||
|
||||
- **Initial render now uses `document.createElement` instead of generating HTML.** Previously we would generate a large string of HTML and then set `node.innerHTML`. At the time, this was decided to be faster than using `document.createElement` for the majority of cases and browsers that we supported. Browsers have continued to improve and so overwhelmingly this is no longer true. By using `createElement` we can make other parts of React faster. ([@spicyj](https://github.com/spicyj) in [#5205](https://github.com/facebook/react/pull/5205))
|
||||
- **`data-reactid` is no longer on every node.** As a result of using `document.createElement`, we can prime the node cache as we create DOM nodes, allowing us to skip a potential lookup (which used the `data-reactid` attribute). Root nodes will have a `data-reactroot` attribute and server generated markup will still contain `data-reactid`. ([@spicyj](https://github.com/spicyj) in [#5205](https://github.com/facebook/react/pull/5205))
|
||||
- **No more extra `<span>`s.** ReactDOM will now render plain text nodes interspersed with comment nodes that are used for demarcation. This gives us the same ability to update individual pieces of text, without creating extra nested nodes. If you were targeting these `<span>`s in your CSS, you will need to adjust accordingly. You can always render them explicitly in your components. ([@mwiencek](https://github.com/mwiencek) in [#5753](https://github.com/facebook/react/pull/5753))
|
||||
- **Rendering `null` now uses comment nodes.** Previously `null` would render to `<noscript>` elements. We now use comment nodes. This may cause issues if making use of `:nth-child` CSS selectors. While we consider this rendering behavior an implementation detail of React, it's worth noting the potential problem. ([@spicyj](https://github.com/spicyj) in [#5451](https://github.com/facebook/react/pull/5451))
|
||||
- **Functional components can now return `null`.** We added support for [defining stateless components as functions](/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components) in React 0.14. However, React 0.14 still allowed you to define a class component without extending `React.Component` or using `React.createClass()`, so [we couldn’t reliably tell if your component is a function or a class](https://github.com/facebook/react/issues/5355), and did not allow returning `null` from it. This issue is solved in React 15, and you can now return `null` from any component, whether it is a class or a function. ([@jimfb](https://github.com/jimfb) in [#5884](https://github.com/facebook/react/pull/5884))
|
||||
- **Improved SVG support.** All SVG tags are now fully supported. (Uncommon SVG tags are not present on the `React.DOM` element helper, but JSX and `React.createElement` work on all tag names.) All SVG attributes that are implemented by the browsers should be supported too. If you find any attributes that we have missed, please [let us know in this issue](https://github.com/facebook/react/issues/1657). ([@zpao](https://github.com/zpao) in [#6243](https://github.com/facebook/react/pull/6243))
|
||||
|
||||
### Breaking changes
|
||||
|
||||
- **No more extra `<span>`s.**
|
||||
- **`React.cloneElement()` now resolves `defaultProps`.** We fixed a bug in `React.cloneElement()` that some components may rely on. If some of the `props` received by `cloneElement()` are `undefined`, it used to return an element with `undefined` values for those props. We’re changing it to be consistent with `createElement()`. Now any `undefined` props passed to `cloneElement()` are resolved to the corresponding component’s `defaultProps`. ([@truongduy134](https://github.com/truongduy134) in [#5997](https://github.com/facebook/react/pull/5997))
|
||||
- **`ReactPerf.getLastMeasurements()` is opaque.** This change won’t affect applications but may break some third-party tools. We are [revamping `ReactPerf` implementation](https://github.com/facebook/react/pull/6046) and plan to release it during the 15.x cycle. The internal performance measurement format is subject to change so, for the time being, we consider the return value of `ReactPerf.getLastMeasurements()` an opaque data structure that should not be relied upon. ([@gaearon](https://github.com/gaearon) in [#6286](https://github.com/facebook/react/pull/6286))
|
||||
|
||||
#### Removed deprecations
|
||||
|
||||
These deprecations were introduced nine months ago in v0.14 with a warning and are removed:
|
||||
|
||||
- Deprecated APIs are removed from the `React` top-level export: `findDOMNode`, `render`, `renderToString`, `renderToStaticMarkup`, and `unmountComponentAtNode`. As a reminder, they are now available on `ReactDOM` and `ReactDOMServer`. ([@jimfb](https://github.com/jimfb) in [#5832](https://github.com/facebook/react/pull/5832))
|
||||
- Deprecated addons are removed: `batchedUpdates` and `cloneWithProps`. ([@jimfb](https://github.com/jimfb) in [#5859](https://github.com/facebook/react/pull/5859), [@zpao](https://github.com/zpao) in [#6016](https://github.com/facebook/react/pull/6016))
|
||||
- Deprecated component instance methods are removed: `setProps`, `replaceProps`, and `getDOMNode`. ([@jimfb](https://github.com/jimfb) in [#5570](https://github.com/facebook/react/pull/5570))
|
||||
- Deprecated CommonJS `react/addons` entry point is removed. As a reminder, you should use separate `react-addons-*` packages instead. This only applies if you use the CommonJS builds. ([@gaearon](https://github.com/gaearon) in [#6285](https://github.com/facebook/react/pull/6285))
|
||||
- Passing `children` to void elements like `<input>` was deprecated, and now throws an error. ([@jonhester](https://github.com/jonhester) in [#3372](https://github.com/facebook/react/pull/3372))
|
||||
- React-specific properties on DOM `refs` (e.g. `this.refs.div.props`) were deprecated, and are removed now. ([@jimfb](https://github.com/jimfb) in [#5495](https://github.com/facebook/react/pull/5495))
|
||||
|
||||
### New deprecations, introduced with a warning
|
||||
|
||||
Each of these changes will continue to work as before with a new warning until the release of React 16 so you can upgrade your code gradually.
|
||||
|
||||
- `LinkedStateMixin` and `valueLink` are now deprecated due to very low popularity. If you need this, you can use a wrapper component that implements the same behavior: [react-linked-input](https://www.npmjs.com/package/react-linked-input). ([@jimfb](https://github.com/jimfb) in [#6127](https://github.com/facebook/react/pull/6127))
|
||||
- Future versions of React will treat `<input value={null}>` as a request to clear the input. However, React 0.14 has been ignoring `value={null}`. React 15 warns you on a `null` input value and offers you to clarify your intention. To fix the warning, you may explicitly pass an empty string to clear a controlled input, or pass `undefined` to make the input uncontrolled. ([@antoaravinth](https://github.com/antoaravinth) in [#5048](https://github.com/facebook/react/pull/5048))
|
||||
- `ReactPerf.printDOM()` was renamed to `ReactPerf.printOperations()`, and `ReactPerf.getMeasurementsSummaryMap()` was renamed to `ReactPerf.getWasted()`. ([@gaearon](https://github.com/gaearon) in [#6287](https://github.com/facebook/react/pull/6287))
|
||||
|
||||
### New helpful warnings
|
||||
|
||||
- If you use a minified copy of the _development_ build, React DOM kindly encourages you to use the faster production build instead. ([@spicyj](https://github.com/spicyj) in [#5083](https://github.com/facebook/react/pull/5083))
|
||||
- React DOM: When specifying a unit-less CSS value as a string, a future version will not add `px` automatically. This version now warns in this case (ex: writing `style={{'{{'}}width: '300'}}`. Unitless *number* values like `width: 300` are unchanged. ([@pluma](https://github.com/pluma) in [#5140](https://github.com/facebook/react/pull/5140))
|
||||
- Synthetic Events will now warn when setting and accessing properties (which will not get cleared appropriately), as well as warn on access after an event has been returned to the pool. ([@kentcdodds](https://github.com/kentcdodds) in [#5940](https://github.com/facebook/react/pull/5940) and [@koba04](https://github.com/koba04) in [#5947](https://github.com/facebook/react/pull/5947))
|
||||
- Elements will now warn when attempting to read `ref` and `key` from the props. ([@prometheansacrifice](https://github.com/prometheansacrifice) in [#5744](https://github.com/facebook/react/pull/5744))
|
||||
- React will now warn if you pass a different `props` object to `super()` in the constructor. ([@prometheansacrifice](https://github.com/prometheansacrifice) in [#5346](https://github.com/facebook/react/pull/5346))
|
||||
- React will now warn if you call `setState()` inside `getChildContext()`. ([@raineroviir](https://github.com/raineroviir) in [#6121](https://github.com/facebook/react/pull/6121))
|
||||
- React DOM now attempts to warn for mistyped event handlers on DOM elements, such as `onclick` which should be `onClick`. ([@ali](https://github.com/ali) in [#5361](https://github.com/facebook/react/pull/5361))
|
||||
- React DOM now warns about `NaN` values in `style`. ([@jontewks](https://github.com/jontewks) in [#5811](https://github.com/facebook/react/pull/5811))
|
||||
- React DOM now warns if you specify both `value` and `defaultValue` for an input. ([@mgmcdermott](https://github.com/mgmcdermott) in [#5823](https://github.com/facebook/react/pull/5823))
|
||||
- React DOM now warns if an input switches between being controlled and uncontrolled. ([@TheBlasfem](https://github.com/TheBlasfem) in [#5864](https://github.com/facebook/react/pull/5864))
|
||||
- React DOM now warns if you specify `onFocusIn` or `onFocusOut` handlers as they are unnecessary in React. ([@jontewks](https://github.com/jontewks) in [#6296](https://github.com/facebook/react/pull/6296))
|
||||
- React now prints a descriptive error message when you pass an invalid callback as the last argument to `ReactDOM.render()`, `this.setState()`, or `this.forceUpdate()`. ([@conorhastings](https://github.com/conorhastings) in [#5193](https://github.com/facebook/react/pull/5193) and [@gaearon](https://github.com/gaearon) in [#6310](https://github.com/facebook/react/pull/6310))
|
||||
- Add-Ons: `TestUtils.Simulate()` now prints a helpful message if you attempt to use it with shallow rendering. ([@conorhastings](https://github.com/conorhastings) in [#5358](https://github.com/facebook/react/pull/5358))
|
||||
- PropTypes: `arrayOf()` and `objectOf()` provide better error messages for invalid arguments. ([@chicoxyzzy](https://github.com/chicoxyzzy) in [#5390](https://github.com/facebook/react/pull/5390))
|
||||
|
||||
### Notable bug fixes
|
||||
|
||||
- Fixed multiple small memory leaks. ([@spicyj](https://github.com/spicyj) in [#4983](https://github.com/facebook/react/pull/4983) and [@victor-homyakov](https://github.com/victor-homyakov) in [#6309](https://github.com/facebook/react/pull/6309))
|
||||
- Input events are handled more reliably in IE 10 and IE 11; spurious events no longer fire when using a placeholder. ([@jquense](https://github.com/jquense) in [#4051](https://github.com/facebook/react/pull/4051))
|
||||
- The `componentWillReceiveProps()` lifecycle method is now consistently called when `context` changes. ([@milesj](https://github.com/milesj) in [#5787](https://github.com/facebook/react/pull/5787))
|
||||
- `React.cloneElement()` doesn’t append slash to an existing `key` when used inside `React.Children.map()`. ([@ianobermiller](https://github.com/ianobermiller) in [#5892](https://github.com/facebook/react/pull/5892))
|
||||
- React DOM now supports the `cite` and `profile` HTML attributes. ([@AprilArcus](https://github.com/AprilArcus) in [#6094](https://github.com/facebook/react/pull/6094) and [@saiichihashimoto](https://github.com/saiichihashimoto) in [#6032](https://github.com/facebook/react/pull/6032))
|
||||
- React DOM now supports `cssFloat`, `gridRow` and `gridColumn` CSS properties. ([@stevenvachon](https://github.com/stevenvachon) in [#6133](https://github.com/facebook/react/pull/6133) and [@mnordick](https://github.com/mnordick) in [#4779](https://github.com/facebook/react/pull/4779))
|
||||
- React DOM now correctly handles `borderImageOutset`, `borderImageWidth`, `borderImageSlice`, `floodOpacity`, `strokeDasharray`, and `strokeMiterlimit` as unitless CSS properties. ([@rofrischmann](https://github.com/rofrischmann) in [#6210](https://github.com/facebook/react/pull/6210) and [#6270](https://github.com/facebook/react/pull/6270))
|
||||
- React DOM now supports the `onAnimationStart`, `onAnimationEnd`, `onAnimationIteration`, `onTransitionEnd`, and `onInvalid` events. Support for `onLoad` has been added to `object` elements. ([@tomduncalf](https://github.com/tomduncalf) in [#5187](https://github.com/facebook/react/pull/5187), [@milesj](https://github.com/milesj) in [#6005](https://github.com/facebook/react/pull/6005), and [@ara4n](https://github.com/ara4n) in [#5781](https://github.com/facebook/react/pull/5781))
|
||||
- React DOM now defaults to using DOM attributes instead of properties, which fixes a few edge case bugs. Additionally the nullification of values (ex: `href={null}`) now results in the forceful removal, no longer trying to set to the default value used by browsers in the absence of a value. ([@syranide](https://github.com/syranide) in [#1510](https://github.com/facebook/react/pull/1510))
|
||||
- React DOM does not mistakingly coerce `children` to strings for Web Components. ([@jimfb](https://github.com/jimfb) in [#5093](https://github.com/facebook/react/pull/5093))
|
||||
- React DOM now correctly normalizes SVG `<use>` events. ([@edmellum](https://github.com/edmellum) in [#5720](https://github.com/facebook/react/pull/5720))
|
||||
- React DOM does not throw if a `<select>` is unmounted while its `onChange` handler is executing. ([@sambev](https://github.com/sambev) in [#6028](https://github.com/facebook/react/pull/6028))
|
||||
- React DOM does not throw in Windows 8 apps. ([@Andrew8xx8](https://github.com/Andrew8xx8) in [#6063](https://github.com/facebook/react/pull/6063))
|
||||
- React DOM does not throw when asynchronously unmounting a child with a `ref`. ([@yiminghe](https://github.com/yiminghe) in [#6095](https://github.com/facebook/react/pull/6095))
|
||||
- React DOM no longer forces synchronous layout because of scroll position tracking. ([@syranide](https://github.com/syranide) in [#2271](https://github.com/facebook/react/pull/2271))
|
||||
- `Object.is` is used in a number of places to compare values, which leads to fewer false positives, especially involving `NaN`. In particular, this affects the `shallowCompare` add-on. ([@chicoxyzzy](https://github.com/chicoxyzzy) in [#6132](https://github.com/facebook/react/pull/6132))
|
||||
- Add-Ons: ReactPerf no longer instruments adding or removing an event listener because they don’t really touch the DOM due to event delegation. ([@antoaravinth](https://github.com/antoaravinth) in [#5209](https://github.com/facebook/react/pull/5209))
|
||||
|
||||
### Other improvements
|
||||
|
||||
- React now uses `loose-envify` instead of `envify` so it installs fewer transitive dependencies. ([@qerub](https://github.com/qerub) in [#6303](https://github.com/facebook/react/pull/6303))
|
||||
- Shallow renderer now exposes `getMountedInstance()`. ([@glenjamin](https://github.com/glenjamin) in [#4918](https://github.com/facebook/react/pull/4918))
|
||||
- Shallow renderer now returns the rendered output from `render()`. ([@simonewebdesign](https://github.com/simonewebdesign) in [#5411](https://github.com/facebook/react/pull/5411))
|
||||
- React no longer depends on ES5 *shams* for `Object.create` and `Object.freeze` in older environments. It still, however, requires ES5 *shims* in those environments. ([@dgreensp](https://github.com/dgreensp) in [#4959](https://github.com/facebook/react/pull/4959))
|
||||
- React DOM now allows `data-` attributes with names that start with numbers. ([@nLight](https://github.com/nLight) in [#5216](https://github.com/facebook/react/pull/5216))
|
||||
- React DOM adds a new `suppressContentEditableWarning` prop for components like [Draft.js](https://facebook.github.io/draft-js/) that intentionally manage `contentEditable` children with React. ([@mxstbr](https://github.com/mxstbr) in [#6112](https://github.com/facebook/react/pull/6112))
|
||||
- React improves the performance for `createClass()` on complex specs. ([@spicyj](https://github.com/spicyj) in [#5550](https://github.com/facebook/react/pull/5550))
|
||||
|
||||
|
||||
## 0.14.8 (March 29, 2016)
|
||||
|
||||
### React
|
||||
@@ -88,7 +518,7 @@
|
||||
### Major changes
|
||||
|
||||
- Split the main `react` package into two: `react` and `react-dom`. This paves the way to writing components that can be shared between the web version of React and React Native. This means you will need to include both files and some functions have been moved from `React` to `ReactDOM`.
|
||||
- Addons have been moved to seperate packages (`react-addons-clone-with-props`, `react-addons-create-fragment`, `react-addons-css-transition-group`, `react-addons-linked-state-mixin`, `react-addons-perf`, `react-addons-pure-render-mixin`, `react-addons-shallow-compare`, `react-addons-test-utils`, `react-addons-transition-group`, `react-addons-update`, `ReactDOM.unstable_batchedUpdates`).
|
||||
- Addons have been moved to separate packages (`react-addons-clone-with-props`, `react-addons-create-fragment`, `react-addons-css-transition-group`, `react-addons-linked-state-mixin`, `react-addons-perf`, `react-addons-pure-render-mixin`, `react-addons-shallow-compare`, `react-addons-test-utils`, `react-addons-transition-group`, `react-addons-update`, `ReactDOM.unstable_batchedUpdates`).
|
||||
- Stateless functional components - React components were previously created using React.createClass or using ES6 classes. This release adds a [new syntax](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) where a user defines a single [stateless render function](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) (with one parameter: `props`) which returns a JSX element, and this function may be used as a component.
|
||||
- Refs to DOM components as the DOM node itself. Previously the only useful thing you can do with a DOM component is call `getDOMNode()` to get the underlying DOM node. Starting with this release, a ref to a DOM component _is_ the actual DOM node. **Note that refs to custom (user-defined) components work exactly as before; only the built-in DOM components are affected by this change.**
|
||||
|
||||
@@ -97,7 +527,7 @@
|
||||
|
||||
- `React.initializeTouchEvents` is no longer necessary and has been removed completely. Touch events now work automatically.
|
||||
- Add-Ons: Due to the DOM node refs change mentioned above, `TestUtils.findAllInRenderedTree` and related helpers are no longer able to take a DOM component, only a custom component.
|
||||
- The `props` object is now frozen, so mutating props after creating a component element is no longer supported. In most cases, [`React.cloneElement`](https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement) should be used instead. This change makes your components easier to reason about and enables the compiler optimizations mentioned above.
|
||||
- The `props` object is now frozen, so mutating props after creating a component element is no longer supported. In most cases, [`React.cloneElement`](https://facebook.github.io/react/docs/react-api.html#cloneelement) should be used instead. This change makes your components easier to reason about and enables the compiler optimizations mentioned above.
|
||||
- Plain objects are no longer supported as React children; arrays should be used instead. You can use the [`createFragment`](https://facebook.github.io/react/docs/create-fragment.html) helper to migrate, which now returns an array.
|
||||
- Add-Ons: `classSet` has been removed. Use [classnames](https://github.com/JedWatson/classnames) instead.
|
||||
- Web components (custom elements) now use native property names. Eg: `class` instead of `className`.
|
||||
@@ -108,7 +538,7 @@
|
||||
- `setProps` and `replaceProps` are now deprecated. Instead, call ReactDOM.render again at the top level with the new props.
|
||||
- ES6 component classes must now extend `React.Component` in order to enable stateless function components. The [ES3 module pattern](https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#other-languages) will continue to work.
|
||||
- Reusing and mutating a `style` object between renders has been deprecated. This mirrors our change to freeze the `props` object.
|
||||
- Add-Ons: `cloneWithProps` is now deprecated. Use [`React.cloneElement`](https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement) instead (unlike `cloneWithProps`, `cloneElement` does not merge `className` or `style` automatically; you can merge them manually if needed).
|
||||
- Add-Ons: `cloneWithProps` is now deprecated. Use [`React.cloneElement`](https://facebook.github.io/react/docs/react-api.html#cloneelement) instead (unlike `cloneWithProps`, `cloneElement` does not merge `className` or `style` automatically; you can merge them manually if needed).
|
||||
- Add-Ons: To improve reliability, `CSSTransitionGroup` will no longer listen to transition events. Instead, you should specify transition durations manually using props such as `transitionEnterTimeout={500}`.
|
||||
|
||||
### Notable enhancements
|
||||
@@ -202,7 +632,7 @@
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* Immutabilty Helpers: Ensure it supports `hasOwnProperty` as an object key
|
||||
* Immutability Helpers: Ensure it supports `hasOwnProperty` as an object key
|
||||
|
||||
### React Tools
|
||||
|
||||
@@ -733,14 +1163,14 @@
|
||||
|
||||
* Upgrade Commoner so `require` statements are no longer relativized when passing through the transformer. This was a feature needed when building React, but doesn't translate well for other consumers of `bin/jsx`.
|
||||
* Upgraded our dependencies on Commoner and Recast so they use a different directory for their cache.
|
||||
* Freeze our esprima dependency.
|
||||
* Freeze our Esprima dependency.
|
||||
|
||||
|
||||
## 0.3.2 (May 31, 2013)
|
||||
|
||||
### JSX
|
||||
|
||||
* Improved compatability with other coding styles (specifically, multiple assignments with a single `var`).
|
||||
* Improved compatibility with other coding styles (specifically, multiple assignments with a single `var`).
|
||||
|
||||
### react-tools
|
||||
|
||||
@@ -756,4 +1186,4 @@
|
||||
|
||||
## 0.3.0 (May 29, 2013)
|
||||
|
||||
* Initial public release
|
||||
* Initial public release
|
||||
@@ -1,100 +1,5 @@
|
||||
# Contributing to React
|
||||
|
||||
React is one of Facebook's first open source projects that is both under very active development and is also being used to ship code to everybody on [facebook.com](https://www.facebook.com). We're still working out the kinks to make contributing to this project as easy and transparent as possible, but we're not quite there yet. Hopefully this document makes the process for contributing clear and answers some questions that you may have.
|
||||
Want to contribute to React? There are a few things you need to know.
|
||||
|
||||
## [Code of Conduct](https://code.facebook.com/codeofconduct)
|
||||
|
||||
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
|
||||
|
||||
## Our Development Process
|
||||
|
||||
Some of the core team will be working directly on GitHub. These changes will be public from the beginning. Other changesets will come via a bridge with Facebook's internal source control. This is a necessity as it allows engineers at Facebook outside of the core team to move fast and contribute from an environment they are comfortable in.
|
||||
|
||||
### `master` is unsafe
|
||||
|
||||
We will do our best to keep `master` in good shape, with tests passing at all times. But in order to move fast, we will make API changes that your application might not be compatible with. We will do our best to communicate these changes and always version appropriately so you can lock into a specific version if need be.
|
||||
|
||||
### Test Suite
|
||||
|
||||
Use `grunt test` to run the full test suite with PhantomJS.
|
||||
|
||||
This command is just a facade to [Jest](https://facebook.github.io/jest/). You may optionally run `npm install -g jest-cli` and use Jest commands directly to have more control over how tests are executed.
|
||||
|
||||
For example, `jest --watch` lets you automatically run the test suite on every file change.
|
||||
|
||||
You can also run a subset of tests by passing a prefix to `jest`. For instance, `jest ReactDOMSVG` will only run tests in the files that start with `ReactDOMSVG`, such as `ReactDOMSVG-test.js`.
|
||||
|
||||
When you know which tests you want to run, you can achieve a fast feedback loop by using these two features together. For example, `jest ReactDOMSVG --watch` will re-run only the matching tests on every change.
|
||||
|
||||
Just make sure to run the whole test suite before submitting a pull request!
|
||||
|
||||
### Pull Requests
|
||||
|
||||
**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
|
||||
|
||||
The core team will be monitoring for pull requests. When we get one, we'll run some Facebook-specific integration tests on it first. From here, we'll need to get another person to sign off on the changes and then merge the pull request. For API changes we may need to fix internal uses, which could cause some delay. We'll do our best to provide updates and feedback throughout the process.
|
||||
|
||||
*Before* submitting a pull request, please make sure the following is done…
|
||||
|
||||
1. Fork the repo and create your branch from `master`.
|
||||
2. If you've added code that should be tested, add tests!
|
||||
3. If you've changed APIs, update the documentation.
|
||||
4. Ensure the test suite passes (`grunt test`).
|
||||
5. Make sure your code lints (`grunt lint`) - we've done our best to make sure these rules match our internal linting guidelines.
|
||||
6. If you haven't already, complete the CLA.
|
||||
|
||||
### Contributor License Agreement (CLA)
|
||||
|
||||
In order to accept your pull request, we need you to submit a CLA. You only need to do this once, so if you've done this for another Facebook open source project, you're good to go. If you are submitting a pull request for the first time, just let us know that you have completed the CLA and we can cross-check with your GitHub username.
|
||||
|
||||
[Complete your CLA here.](https://code.facebook.com/cla)
|
||||
|
||||
## Bugs
|
||||
|
||||
### Where to Find Known Issues
|
||||
|
||||
We will be using GitHub Issues for our public bugs. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new task, try to make sure your problem doesn't already exist.
|
||||
|
||||
### Reporting New Issues
|
||||
|
||||
The best way to get your bug fixed is to provide a reduced test case. jsFiddle, jsBin, and other sites provide a way to give live examples. Those are especially helpful though may not work for `JSX`-based code.
|
||||
|
||||
### Security Bugs
|
||||
|
||||
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page.
|
||||
|
||||
## How to Get in Touch
|
||||
|
||||
* IRC - [#reactjs on freenode](https://webchat.freenode.net/?channels=reactjs)
|
||||
* Discussion forum - [discuss.reactjs.org](https://discuss.reactjs.org/)
|
||||
|
||||
## Meeting Notes
|
||||
|
||||
React team meets once a week to discuss the development of React, future plans, and priorities.
|
||||
You can find the meeting notes in a [dedicated repository](https://github.com/reactjs/core-notes/).
|
||||
|
||||
## Style Guide
|
||||
|
||||
Our linter will catch most styling issues that may exist in your code.
|
||||
You can check the status of your code styling by simply running: `grunt lint`
|
||||
|
||||
However, there are still some styles that the linter cannot pick up. If you are unsure about something, looking at [Airbnb's Style Guide](https://github.com/airbnb/javascript) will guide you in the right direction.
|
||||
|
||||
### Code Conventions
|
||||
|
||||
* Use semicolons `;`
|
||||
* Commas last `,`
|
||||
* 2 spaces for indentation (no tabs)
|
||||
* Prefer `'` over `"`
|
||||
* `'use strict';`
|
||||
* 80 character line length
|
||||
* Write "attractive" code
|
||||
* Do not use the optional parameters of `setTimeout` and `setInterval`
|
||||
|
||||
### Documentation
|
||||
|
||||
* Do not wrap lines at 80 characters
|
||||
|
||||
## License
|
||||
|
||||
By contributing to React, you agree that your contributions will be licensed under its BSD license.
|
||||
We wrote a **[contribution guide](https://facebook.github.io/react/contributing/how-to-contribute.html)** to help you get started.
|
||||
|
||||
68
Gruntfile.js
68
Gruntfile.js
@@ -23,8 +23,6 @@ module.exports = function(grunt) {
|
||||
'compare_size': require('./grunt/config/compare_size'),
|
||||
});
|
||||
|
||||
grunt.config.set('compress', require('./grunt/config/compress'));
|
||||
|
||||
function spawnGulp(args, opts, done) {
|
||||
|
||||
grunt.util.spawn({
|
||||
@@ -52,10 +50,18 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks(npmTaskName);
|
||||
});
|
||||
|
||||
grunt.registerTask('eslint', require('./grunt/tasks/eslint'));
|
||||
grunt.registerTask('eslint', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['eslint'], null, this.async());
|
||||
});
|
||||
|
||||
grunt.registerTask('lint', ['eslint']);
|
||||
|
||||
grunt.registerTask('flow', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['flow'], null, this.async());
|
||||
});
|
||||
|
||||
grunt.registerTask('delete-build-modules', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['react:clean'], null, this.async());
|
||||
@@ -74,11 +80,14 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('npm-react-dom:release', npmReactDOMTasks.buildRelease);
|
||||
grunt.registerTask('npm-react-dom:pack', npmReactDOMTasks.packRelease);
|
||||
|
||||
var npmReactAddonsTasks = require('./grunt/tasks/npm-react-addons');
|
||||
grunt.registerTask('npm-react-addons:release', npmReactAddonsTasks.buildReleases);
|
||||
grunt.registerTask('npm-react-addons:pack', npmReactAddonsTasks.packReleases);
|
||||
var npmReactTestRendererTasks = require('./grunt/tasks/npm-react-test');
|
||||
grunt.registerTask('npm-react-test:release', npmReactTestRendererTasks.buildRelease);
|
||||
grunt.registerTask('npm-react-test:pack', npmReactTestRendererTasks.packRelease);
|
||||
|
||||
grunt.registerTask('version-check', require('./grunt/tasks/version-check'));
|
||||
grunt.registerTask('version-check', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['version-check'], null, this.async());
|
||||
});
|
||||
|
||||
grunt.registerTask('build:basic', [
|
||||
'build-modules',
|
||||
@@ -98,12 +107,41 @@ module.exports = function(grunt) {
|
||||
'build-modules',
|
||||
'browserify:addonsMin',
|
||||
]);
|
||||
grunt.registerTask('build:dom', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:dom',
|
||||
]);
|
||||
grunt.registerTask('build:dom-min', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domMin',
|
||||
]);
|
||||
grunt.registerTask('build:dom-server', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domServer',
|
||||
]);
|
||||
grunt.registerTask('build:dom-server-min', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domServerMin',
|
||||
]);
|
||||
grunt.registerTask('build:dom-fiber', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domFiber',
|
||||
]);
|
||||
grunt.registerTask('build:dom-fiber-min', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domFiberMin',
|
||||
]);
|
||||
grunt.registerTask('build:npm-react', [
|
||||
'version-check',
|
||||
'build-modules',
|
||||
'npm-react:release',
|
||||
]);
|
||||
grunt.registerTask('build:react-dom', require('./grunt/tasks/react-dom'));
|
||||
|
||||
var jestTasks = require('./grunt/tasks/jest');
|
||||
grunt.registerTask('jest:normal', jestTasks.normal);
|
||||
@@ -122,13 +160,18 @@ module.exports = function(grunt) {
|
||||
'browserify:addons',
|
||||
'browserify:min',
|
||||
'browserify:addonsMin',
|
||||
'build:react-dom',
|
||||
'browserify:dom',
|
||||
'browserify:domMin',
|
||||
'browserify:domServer',
|
||||
'browserify:domServerMin',
|
||||
'browserify:domFiber',
|
||||
'browserify:domFiberMin',
|
||||
'npm-react:release',
|
||||
'npm-react:pack',
|
||||
'npm-react-dom:release',
|
||||
'npm-react-dom:pack',
|
||||
'npm-react-addons:release',
|
||||
'npm-react-addons:pack',
|
||||
'npm-react-test:release',
|
||||
'npm-react-test:pack',
|
||||
'compare_size',
|
||||
]);
|
||||
|
||||
@@ -138,15 +181,12 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('release:bower', releaseTasks.bower);
|
||||
grunt.registerTask('release:docs', releaseTasks.docs);
|
||||
grunt.registerTask('release:msg', releaseTasks.msg);
|
||||
grunt.registerTask('release:starter', releaseTasks.starter);
|
||||
|
||||
grunt.registerTask('release', [
|
||||
'release:setup',
|
||||
'clean',
|
||||
'build',
|
||||
'release:bower',
|
||||
'release:starter',
|
||||
'compress',
|
||||
'release:docs',
|
||||
'release:msg',
|
||||
]);
|
||||
|
||||
87
README.md
87
README.md
@@ -2,11 +2,9 @@
|
||||
|
||||
React is a JavaScript library for building user interfaces.
|
||||
|
||||
* **Just the UI:** Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.
|
||||
* **Virtual DOM:** React abstracts away the DOM from you, giving a simpler programming model and better performance. React can also render on the server using Node, and it can power native apps using [React Native](https://facebook.github.io/react-native/).
|
||||
* **Data flow:** React implements one-way reactive data flow which reduces boilerplate and is easier to reason about than traditional data binding.
|
||||
|
||||
**NEW**! Check out our newest project [React Native](https://github.com/facebook/react-native), which uses React and JavaScript to create native mobile apps.
|
||||
* **Declarative:** React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable, simpler to understand, and easier to debug.
|
||||
* **Component-Based:** Build encapsulated components that manage their own state, then compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.
|
||||
* **Learn Once, Write Anywhere:** We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code. React can also render on the server using Node and power mobile apps using [React Native](https://facebook.github.io/react-native/).
|
||||
|
||||
[Learn how to use React in your own project](https://facebook.github.io/react/docs/getting-started.html).
|
||||
|
||||
@@ -15,11 +13,11 @@ React is a JavaScript library for building user interfaces.
|
||||
We have several examples [on the website](https://facebook.github.io/react/). Here is the first one to get you started:
|
||||
|
||||
```js
|
||||
var HelloMessage = React.createClass({
|
||||
render: function() {
|
||||
class HelloMessage extends React.Component {
|
||||
render() {
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<HelloMessage name="John" />,
|
||||
@@ -29,76 +27,31 @@ ReactDOM.render(
|
||||
|
||||
This example will render "Hello John" into a container on the page.
|
||||
|
||||
You'll notice that we used an HTML-like syntax; [we call it JSX](https://facebook.github.io/react/docs/jsx-in-depth.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. A simple transform is included with React that allows converting JSX into native JavaScript for browsers to digest.
|
||||
You'll notice that we used an HTML-like syntax; [we call it JSX](https://facebook.github.io/react/docs/introducing-jsx.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. We recommend using [Babel](https://babeljs.io/) with a [React preset](https://babeljs.io/docs/plugins/preset-react/) to convert JSX into native JavaScript for browsers to digest.
|
||||
|
||||
## Installation
|
||||
|
||||
The fastest way to get started is to serve JavaScript from the CDN (also available on [cdnjs](https://cdnjs.com/libraries/react) and [jsdelivr](https://www.jsdelivr.com/projects/react)):
|
||||
React is available as the `react` package on [npm](https://www.npmjs.com/). It is also available on a [CDN](https://facebook.github.io/react/docs/installation.html#using-a-cdn).
|
||||
|
||||
```html
|
||||
<!-- The core React library -->
|
||||
<script src="https://fb.me/react-0.14.8.js"></script>
|
||||
<!-- The ReactDOM Library -->
|
||||
<script src="https://fb.me/react-dom-0.14.8.js"></script>
|
||||
```
|
||||
React is flexible and can be used in a variety of projects. You can create new apps with it, but you can also gradually introduce it into an existing codebase without doing a rewrite.
|
||||
|
||||
We've also built a [starter kit](https://facebook.github.io/react/downloads/react-0.14.8.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
|
||||
The recommended way to install React depends on your project. Here you can find short guides for the most common scenarios:
|
||||
|
||||
If you'd like to use [bower](http://bower.io), it's as easy as:
|
||||
* [Trying Out React](https://facebook.github.io/react/docs/installation.html#trying-out-react)
|
||||
* [Creating a Single Page Application](https://facebook.github.io/react/docs/installation.html#creating-a-single-page-application)
|
||||
* [Adding React to an Existing Application](https://facebook.github.io/react/docs/installation.html#adding-react-to-an-existing-application)
|
||||
|
||||
```sh
|
||||
bower install --save react
|
||||
```
|
||||
## Contributing
|
||||
|
||||
And it's just as easy with [npm](http://npmjs.com):
|
||||
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, check out our [contribution guide](https://facebook.github.io/react/contributing/how-to-contribute.html).
|
||||
|
||||
```sh
|
||||
npm i --save react
|
||||
```
|
||||
### [Code of Conduct](https://code.facebook.com/codeofconduct)
|
||||
|
||||
## Contribute
|
||||
|
||||
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, then keep reading. If you're not interested in helping right now that's ok too. :) Any feedback you have about using React would be greatly appreciated.
|
||||
|
||||
### Building Your Copy of React
|
||||
|
||||
The process to build `react.js` is built entirely on top of node.js, using many libraries you may already be familiar with.
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
* You have `node` installed at v4.0.0+ and `npm` at v2.0.0+.
|
||||
* You are familiar with `npm` and know whether or not you need to use `sudo` when installing packages globally.
|
||||
* You are familiar with `git`.
|
||||
|
||||
#### Build
|
||||
|
||||
Once you have the repository cloned, building a copy of `react.js` is really easy.
|
||||
|
||||
```sh
|
||||
# grunt-cli is needed by grunt; you might have this installed already
|
||||
npm install -g grunt-cli
|
||||
npm install
|
||||
grunt build
|
||||
```
|
||||
|
||||
At this point, you should now have a `build/` directory populated with everything you need to use React. The examples should all work.
|
||||
|
||||
### Grunt
|
||||
|
||||
We use grunt to automate many tasks. Run `grunt -h` to see a mostly complete listing. The important ones to know:
|
||||
|
||||
```sh
|
||||
# Build and run tests with PhantomJS
|
||||
grunt test
|
||||
# Lint the code with ESLint
|
||||
grunt lint
|
||||
# Wipe out build directory
|
||||
grunt clean
|
||||
```
|
||||
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
|
||||
|
||||
### Good First Bug
|
||||
To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first bugs](https://github.com/facebook/react/labels/good%20first%20bug) that contain bugs which are fairly easy to fix. This is a great place to get started.
|
||||
|
||||
To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first bugs](https://github.com/facebook/react/labels/good%20first%20bug) that contain bugs which are fairly easy to fix. This is a great place to get started.
|
||||
|
||||
### License
|
||||
|
||||
@@ -108,9 +61,5 @@ React documentation is [Creative Commons licensed](./LICENSE-docs).
|
||||
|
||||
Examples provided in this repository and in the documentation are [separately licensed](./LICENSE-examples).
|
||||
|
||||
### More…
|
||||
|
||||
There's only so much we can cram in here. To read more about the community and guidelines for submitting pull requests, please read the [Contributing document](CONTRIBUTING.md).
|
||||
|
||||
## Troubleshooting
|
||||
See the [Troubleshooting Guide](https://github.com/facebook/react/wiki/Troubleshooting)
|
||||
|
||||
5
addons/.eslintrc
Normal file
5
addons/.eslintrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"rules": {
|
||||
"comma-dangle": 0
|
||||
}
|
||||
}
|
||||
2
addons/create-react-class/.gitignore
vendored
Normal file
2
addons/create-react-class/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
create-react-class.js
|
||||
create-react-class.min.js
|
||||
31
addons/create-react-class/LICENSE.txt
Normal file
31
addons/create-react-class/LICENSE.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/create-react-class/PATENTS
Normal file
33
addons/create-react-class/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
5
addons/create-react-class/README.md
Normal file
5
addons/create-react-class/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# create-react-class
|
||||
|
||||
A drop-in replacement for `React.createClass`.
|
||||
|
||||
Refer to the [React documentation](https://facebook.github.io/react/docs/react-without-es6.html) for more information.
|
||||
872
addons/create-react-class/factory.js
Normal file
872
addons/create-react-class/factory.js
Normal file
@@ -0,0 +1,872 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _assign = require('object-assign');
|
||||
|
||||
var emptyObject = require('fbjs/lib/emptyObject');
|
||||
var _invariant = require('fbjs/lib/invariant');
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
var MIXINS_KEY = 'mixins';
|
||||
|
||||
// Helper function to allow the creation of anonymous functions which do not
|
||||
// have .name set to the name of the variable being assigned to.
|
||||
function identity(fn) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
var ReactPropTypeLocationNames;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ReactPropTypeLocationNames = {
|
||||
prop: 'prop',
|
||||
context: 'context',
|
||||
childContext: 'child context'
|
||||
};
|
||||
} else {
|
||||
ReactPropTypeLocationNames = {};
|
||||
}
|
||||
|
||||
function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
/**
|
||||
* Policies that describe methods in `ReactClassInterface`.
|
||||
*/
|
||||
|
||||
var injectedMixins = [];
|
||||
|
||||
/**
|
||||
* Composite components are higher-level components that compose other composite
|
||||
* or host components.
|
||||
*
|
||||
* To create a new type of `ReactClass`, pass a specification of
|
||||
* your new class to `React.createClass`. The only requirement of your class
|
||||
* specification is that you implement a `render` method.
|
||||
*
|
||||
* var MyComponent = React.createClass({
|
||||
* render: function() {
|
||||
* return <div>Hello World</div>;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* The class specification supports a specific protocol of methods that have
|
||||
* special meaning (e.g. `render`). See `ReactClassInterface` for
|
||||
* more the comprehensive protocol. Any other properties and methods in the
|
||||
* class specification will be available on the prototype.
|
||||
*
|
||||
* @interface ReactClassInterface
|
||||
* @internal
|
||||
*/
|
||||
var ReactClassInterface = {
|
||||
/**
|
||||
* An array of Mixin objects to include when defining your component.
|
||||
*
|
||||
* @type {array}
|
||||
* @optional
|
||||
*/
|
||||
mixins: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* An object containing properties and methods that should be defined on
|
||||
* the component's constructor instead of its prototype (static methods).
|
||||
*
|
||||
* @type {object}
|
||||
* @optional
|
||||
*/
|
||||
statics: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Definition of prop types for this component.
|
||||
*
|
||||
* @type {object}
|
||||
* @optional
|
||||
*/
|
||||
propTypes: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Definition of context types for this component.
|
||||
*
|
||||
* @type {object}
|
||||
* @optional
|
||||
*/
|
||||
contextTypes: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Definition of context types this component sets for its children.
|
||||
*
|
||||
* @type {object}
|
||||
* @optional
|
||||
*/
|
||||
childContextTypes: 'DEFINE_MANY',
|
||||
|
||||
// ==== Definition methods ====
|
||||
|
||||
/**
|
||||
* Invoked when the component is mounted. Values in the mapping will be set on
|
||||
* `this.props` if that prop is not specified (i.e. using an `in` check).
|
||||
*
|
||||
* This method is invoked before `getInitialState` and therefore cannot rely
|
||||
* on `this.state` or use `this.setState`.
|
||||
*
|
||||
* @return {object}
|
||||
* @optional
|
||||
*/
|
||||
getDefaultProps: 'DEFINE_MANY_MERGED',
|
||||
|
||||
/**
|
||||
* Invoked once before the component is mounted. The return value will be used
|
||||
* as the initial value of `this.state`.
|
||||
*
|
||||
* getInitialState: function() {
|
||||
* return {
|
||||
* isOn: false,
|
||||
* fooBaz: new BazFoo()
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @return {object}
|
||||
* @optional
|
||||
*/
|
||||
getInitialState: 'DEFINE_MANY_MERGED',
|
||||
|
||||
/**
|
||||
* @return {object}
|
||||
* @optional
|
||||
*/
|
||||
getChildContext: 'DEFINE_MANY_MERGED',
|
||||
|
||||
/**
|
||||
* Uses props from `this.props` and state from `this.state` to render the
|
||||
* structure of the component.
|
||||
*
|
||||
* No guarantees are made about when or how often this method is invoked, so
|
||||
* it must not have side effects.
|
||||
*
|
||||
* render: function() {
|
||||
* var name = this.props.name;
|
||||
* return <div>Hello, {name}!</div>;
|
||||
* }
|
||||
*
|
||||
* @return {ReactComponent}
|
||||
* @required
|
||||
*/
|
||||
render: 'DEFINE_ONCE',
|
||||
|
||||
// ==== Delegate methods ====
|
||||
|
||||
/**
|
||||
* Invoked when the component is initially created and about to be mounted.
|
||||
* This may have side effects, but any external subscriptions or data created
|
||||
* by this method must be cleaned up in `componentWillUnmount`.
|
||||
*
|
||||
* @optional
|
||||
*/
|
||||
componentWillMount: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Invoked when the component has been mounted and has a DOM representation.
|
||||
* However, there is no guarantee that the DOM node is in the document.
|
||||
*
|
||||
* Use this as an opportunity to operate on the DOM when the component has
|
||||
* been mounted (initialized and rendered) for the first time.
|
||||
*
|
||||
* @param {DOMElement} rootNode DOM element representing the component.
|
||||
* @optional
|
||||
*/
|
||||
componentDidMount: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Invoked before the component receives new props.
|
||||
*
|
||||
* Use this as an opportunity to react to a prop transition by updating the
|
||||
* state using `this.setState`. Current props are accessed via `this.props`.
|
||||
*
|
||||
* componentWillReceiveProps: function(nextProps, nextContext) {
|
||||
* this.setState({
|
||||
* likesIncreasing: nextProps.likeCount > this.props.likeCount
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
|
||||
* transition may cause a state change, but the opposite is not true. If you
|
||||
* need it, you are probably looking for `componentWillUpdate`.
|
||||
*
|
||||
* @param {object} nextProps
|
||||
* @optional
|
||||
*/
|
||||
componentWillReceiveProps: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Invoked while deciding if the component should be updated as a result of
|
||||
* receiving new props, state and/or context.
|
||||
*
|
||||
* Use this as an opportunity to `return false` when you're certain that the
|
||||
* transition to the new props/state/context will not require a component
|
||||
* update.
|
||||
*
|
||||
* shouldComponentUpdate: function(nextProps, nextState, nextContext) {
|
||||
* return !equal(nextProps, this.props) ||
|
||||
* !equal(nextState, this.state) ||
|
||||
* !equal(nextContext, this.context);
|
||||
* }
|
||||
*
|
||||
* @param {object} nextProps
|
||||
* @param {?object} nextState
|
||||
* @param {?object} nextContext
|
||||
* @return {boolean} True if the component should update.
|
||||
* @optional
|
||||
*/
|
||||
shouldComponentUpdate: 'DEFINE_ONCE',
|
||||
|
||||
/**
|
||||
* Invoked when the component is about to update due to a transition from
|
||||
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
|
||||
* and `nextContext`.
|
||||
*
|
||||
* Use this as an opportunity to perform preparation before an update occurs.
|
||||
*
|
||||
* NOTE: You **cannot** use `this.setState()` in this method.
|
||||
*
|
||||
* @param {object} nextProps
|
||||
* @param {?object} nextState
|
||||
* @param {?object} nextContext
|
||||
* @param {ReactReconcileTransaction} transaction
|
||||
* @optional
|
||||
*/
|
||||
componentWillUpdate: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Invoked when the component's DOM representation has been updated.
|
||||
*
|
||||
* Use this as an opportunity to operate on the DOM when the component has
|
||||
* been updated.
|
||||
*
|
||||
* @param {object} prevProps
|
||||
* @param {?object} prevState
|
||||
* @param {?object} prevContext
|
||||
* @param {DOMElement} rootNode DOM element representing the component.
|
||||
* @optional
|
||||
*/
|
||||
componentDidUpdate: 'DEFINE_MANY',
|
||||
|
||||
/**
|
||||
* Invoked when the component is about to be removed from its parent and have
|
||||
* its DOM representation destroyed.
|
||||
*
|
||||
* Use this as an opportunity to deallocate any external resources.
|
||||
*
|
||||
* NOTE: There is no `componentDidUnmount` since your component will have been
|
||||
* destroyed by that point.
|
||||
*
|
||||
* @optional
|
||||
*/
|
||||
componentWillUnmount: 'DEFINE_MANY',
|
||||
|
||||
// ==== Advanced methods ====
|
||||
|
||||
/**
|
||||
* Updates the component's currently mounted DOM representation.
|
||||
*
|
||||
* By default, this implements React's rendering and reconciliation algorithm.
|
||||
* Sophisticated clients may wish to override this.
|
||||
*
|
||||
* @param {ReactReconcileTransaction} transaction
|
||||
* @internal
|
||||
* @overridable
|
||||
*/
|
||||
updateComponent: 'OVERRIDE_BASE'
|
||||
};
|
||||
|
||||
/**
|
||||
* Mapping from class specification keys to special processing functions.
|
||||
*
|
||||
* Although these are declared like instance properties in the specification
|
||||
* when defining classes using `React.createClass`, they are actually static
|
||||
* and are accessible on the constructor instead of the prototype. Despite
|
||||
* being static, they must be defined outside of the "statics" key under
|
||||
* which all other static methods are defined.
|
||||
*/
|
||||
var RESERVED_SPEC_KEYS = {
|
||||
displayName: function(Constructor, displayName) {
|
||||
Constructor.displayName = displayName;
|
||||
},
|
||||
mixins: function(Constructor, mixins) {
|
||||
if (mixins) {
|
||||
for (var i = 0; i < mixins.length; i++) {
|
||||
mixSpecIntoComponent(Constructor, mixins[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
childContextTypes: function(Constructor, childContextTypes) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateTypeDef(Constructor, childContextTypes, 'childContext');
|
||||
}
|
||||
Constructor.childContextTypes = _assign(
|
||||
{},
|
||||
Constructor.childContextTypes,
|
||||
childContextTypes
|
||||
);
|
||||
},
|
||||
contextTypes: function(Constructor, contextTypes) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateTypeDef(Constructor, contextTypes, 'context');
|
||||
}
|
||||
Constructor.contextTypes = _assign(
|
||||
{},
|
||||
Constructor.contextTypes,
|
||||
contextTypes
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Special case getDefaultProps which should move into statics but requires
|
||||
* automatic merging.
|
||||
*/
|
||||
getDefaultProps: function(Constructor, getDefaultProps) {
|
||||
if (Constructor.getDefaultProps) {
|
||||
Constructor.getDefaultProps = createMergedResultFunction(
|
||||
Constructor.getDefaultProps,
|
||||
getDefaultProps
|
||||
);
|
||||
} else {
|
||||
Constructor.getDefaultProps = getDefaultProps;
|
||||
}
|
||||
},
|
||||
propTypes: function(Constructor, propTypes) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateTypeDef(Constructor, propTypes, 'prop');
|
||||
}
|
||||
Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);
|
||||
},
|
||||
statics: function(Constructor, statics) {
|
||||
mixStaticSpecIntoComponent(Constructor, statics);
|
||||
},
|
||||
autobind: function() {}
|
||||
};
|
||||
|
||||
function validateTypeDef(Constructor, typeDef, location) {
|
||||
for (var propName in typeDef) {
|
||||
if (typeDef.hasOwnProperty(propName)) {
|
||||
// use a warning instead of an _invariant so components
|
||||
// don't show up in prod but only in __DEV__
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(
|
||||
typeof typeDef[propName] === 'function',
|
||||
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
|
||||
'React.PropTypes.',
|
||||
Constructor.displayName || 'ReactClass',
|
||||
ReactPropTypeLocationNames[location],
|
||||
propName
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateMethodOverride(isAlreadyDefined, name) {
|
||||
var specPolicy = ReactClassInterface.hasOwnProperty(name)
|
||||
? ReactClassInterface[name]
|
||||
: null;
|
||||
|
||||
// Disallow overriding of base class methods unless explicitly allowed.
|
||||
if (ReactClassMixin.hasOwnProperty(name)) {
|
||||
_invariant(
|
||||
specPolicy === 'OVERRIDE_BASE',
|
||||
'ReactClassInterface: You are attempting to override ' +
|
||||
'`%s` from your class specification. Ensure that your method names ' +
|
||||
'do not overlap with React methods.',
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
// Disallow defining methods more than once unless explicitly allowed.
|
||||
if (isAlreadyDefined) {
|
||||
_invariant(
|
||||
specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED',
|
||||
'ReactClassInterface: You are attempting to define ' +
|
||||
'`%s` on your component more than once. This conflict may be due ' +
|
||||
'to a mixin.',
|
||||
name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixin helper which handles policy validation and reserved
|
||||
* specification keys when building React classes.
|
||||
*/
|
||||
function mixSpecIntoComponent(Constructor, spec) {
|
||||
if (!spec) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var typeofSpec = typeof spec;
|
||||
var isMixinValid = typeofSpec === 'object' && spec !== null;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(
|
||||
isMixinValid,
|
||||
"%s: You're attempting to include a mixin that is either null " +
|
||||
'or not an object. Check the mixins included by the component, ' +
|
||||
'as well as any mixins they include themselves. ' +
|
||||
'Expected object but got %s.',
|
||||
Constructor.displayName || 'ReactClass',
|
||||
spec === null ? null : typeofSpec
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_invariant(
|
||||
typeof spec !== 'function',
|
||||
"ReactClass: You're attempting to " +
|
||||
'use a component class or function as a mixin. Instead, just use a ' +
|
||||
'regular object.'
|
||||
);
|
||||
_invariant(
|
||||
!isValidElement(spec),
|
||||
"ReactClass: You're attempting to " +
|
||||
'use a component as a mixin. Instead, just use a regular object.'
|
||||
);
|
||||
|
||||
var proto = Constructor.prototype;
|
||||
var autoBindPairs = proto.__reactAutoBindPairs;
|
||||
|
||||
// By handling mixins before any other properties, we ensure the same
|
||||
// chaining order is applied to methods with DEFINE_MANY policy, whether
|
||||
// mixins are listed before or after these methods in the spec.
|
||||
if (spec.hasOwnProperty(MIXINS_KEY)) {
|
||||
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
|
||||
}
|
||||
|
||||
for (var name in spec) {
|
||||
if (!spec.hasOwnProperty(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name === MIXINS_KEY) {
|
||||
// We have already handled mixins in a special case above.
|
||||
continue;
|
||||
}
|
||||
|
||||
var property = spec[name];
|
||||
var isAlreadyDefined = proto.hasOwnProperty(name);
|
||||
validateMethodOverride(isAlreadyDefined, name);
|
||||
|
||||
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
|
||||
RESERVED_SPEC_KEYS[name](Constructor, property);
|
||||
} else {
|
||||
// Setup methods on prototype:
|
||||
// The following member methods should not be automatically bound:
|
||||
// 1. Expected ReactClass methods (in the "interface").
|
||||
// 2. Overridden methods (that were mixed in).
|
||||
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
|
||||
var isFunction = typeof property === 'function';
|
||||
var shouldAutoBind =
|
||||
isFunction &&
|
||||
!isReactClassMethod &&
|
||||
!isAlreadyDefined &&
|
||||
spec.autobind !== false;
|
||||
|
||||
if (shouldAutoBind) {
|
||||
autoBindPairs.push(name, property);
|
||||
proto[name] = property;
|
||||
} else {
|
||||
if (isAlreadyDefined) {
|
||||
var specPolicy = ReactClassInterface[name];
|
||||
|
||||
// These cases should already be caught by validateMethodOverride.
|
||||
_invariant(
|
||||
isReactClassMethod &&
|
||||
(specPolicy === 'DEFINE_MANY_MERGED' ||
|
||||
specPolicy === 'DEFINE_MANY'),
|
||||
'ReactClass: Unexpected spec policy %s for key %s ' +
|
||||
'when mixing in component specs.',
|
||||
specPolicy,
|
||||
name
|
||||
);
|
||||
|
||||
// For methods which are defined more than once, call the existing
|
||||
// methods before calling the new property, merging if appropriate.
|
||||
if (specPolicy === 'DEFINE_MANY_MERGED') {
|
||||
proto[name] = createMergedResultFunction(proto[name], property);
|
||||
} else if (specPolicy === 'DEFINE_MANY') {
|
||||
proto[name] = createChainedFunction(proto[name], property);
|
||||
}
|
||||
} else {
|
||||
proto[name] = property;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// Add verbose displayName to the function, which helps when looking
|
||||
// at profiling tools.
|
||||
if (typeof property === 'function' && spec.displayName) {
|
||||
proto[name].displayName = spec.displayName + '_' + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mixStaticSpecIntoComponent(Constructor, statics) {
|
||||
if (!statics) {
|
||||
return;
|
||||
}
|
||||
for (var name in statics) {
|
||||
var property = statics[name];
|
||||
if (!statics.hasOwnProperty(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var isReserved = name in RESERVED_SPEC_KEYS;
|
||||
_invariant(
|
||||
!isReserved,
|
||||
'ReactClass: You are attempting to define a reserved ' +
|
||||
'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
|
||||
'as an instance property instead; it will still be accessible on the ' +
|
||||
'constructor.',
|
||||
name
|
||||
);
|
||||
|
||||
var isInherited = name in Constructor;
|
||||
_invariant(
|
||||
!isInherited,
|
||||
'ReactClass: You are attempting to define ' +
|
||||
'`%s` on your component more than once. This conflict may be ' +
|
||||
'due to a mixin.',
|
||||
name
|
||||
);
|
||||
Constructor[name] = property;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge two objects, but throw if both contain the same key.
|
||||
*
|
||||
* @param {object} one The first object, which is mutated.
|
||||
* @param {object} two The second object
|
||||
* @return {object} one after it has been mutated to contain everything in two.
|
||||
*/
|
||||
function mergeIntoWithNoDuplicateKeys(one, two) {
|
||||
_invariant(
|
||||
one && two && typeof one === 'object' && typeof two === 'object',
|
||||
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
|
||||
);
|
||||
|
||||
for (var key in two) {
|
||||
if (two.hasOwnProperty(key)) {
|
||||
_invariant(
|
||||
one[key] === undefined,
|
||||
'mergeIntoWithNoDuplicateKeys(): ' +
|
||||
'Tried to merge two objects with the same key: `%s`. This conflict ' +
|
||||
'may be due to a mixin; in particular, this may be caused by two ' +
|
||||
'getInitialState() or getDefaultProps() methods returning objects ' +
|
||||
'with clashing keys.',
|
||||
key
|
||||
);
|
||||
one[key] = two[key];
|
||||
}
|
||||
}
|
||||
return one;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that invokes two functions and merges their return values.
|
||||
*
|
||||
* @param {function} one Function to invoke first.
|
||||
* @param {function} two Function to invoke second.
|
||||
* @return {function} Function that invokes the two argument functions.
|
||||
* @private
|
||||
*/
|
||||
function createMergedResultFunction(one, two) {
|
||||
return function mergedResult() {
|
||||
var a = one.apply(this, arguments);
|
||||
var b = two.apply(this, arguments);
|
||||
if (a == null) {
|
||||
return b;
|
||||
} else if (b == null) {
|
||||
return a;
|
||||
}
|
||||
var c = {};
|
||||
mergeIntoWithNoDuplicateKeys(c, a);
|
||||
mergeIntoWithNoDuplicateKeys(c, b);
|
||||
return c;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that invokes two functions and ignores their return vales.
|
||||
*
|
||||
* @param {function} one Function to invoke first.
|
||||
* @param {function} two Function to invoke second.
|
||||
* @return {function} Function that invokes the two argument functions.
|
||||
* @private
|
||||
*/
|
||||
function createChainedFunction(one, two) {
|
||||
return function chainedFunction() {
|
||||
one.apply(this, arguments);
|
||||
two.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a method to the component.
|
||||
*
|
||||
* @param {object} component Component whose method is going to be bound.
|
||||
* @param {function} method Method to be bound.
|
||||
* @return {function} The bound method.
|
||||
*/
|
||||
function bindAutoBindMethod(component, method) {
|
||||
var boundMethod = method.bind(component);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
boundMethod.__reactBoundContext = component;
|
||||
boundMethod.__reactBoundMethod = method;
|
||||
boundMethod.__reactBoundArguments = null;
|
||||
var componentName = component.constructor.displayName;
|
||||
var _bind = boundMethod.bind;
|
||||
boundMethod.bind = function(newThis) {
|
||||
for (
|
||||
var _len = arguments.length,
|
||||
args = Array(_len > 1 ? _len - 1 : 0),
|
||||
_key = 1;
|
||||
_key < _len;
|
||||
_key++
|
||||
) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
// User is trying to bind() an autobound method; we effectively will
|
||||
// ignore the value of "this" that the user is trying to use, so
|
||||
// let's warn.
|
||||
if (newThis !== component && newThis !== null) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(
|
||||
false,
|
||||
'bind(): React component methods may only be bound to the ' +
|
||||
'component instance. See %s',
|
||||
componentName
|
||||
);
|
||||
}
|
||||
} else if (!args.length) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(
|
||||
false,
|
||||
'bind(): You are binding a component method to the component. ' +
|
||||
'React does this for you automatically in a high-performance ' +
|
||||
'way, so you can safely remove this call. See %s',
|
||||
componentName
|
||||
);
|
||||
}
|
||||
return boundMethod;
|
||||
}
|
||||
var reboundMethod = _bind.apply(boundMethod, arguments);
|
||||
reboundMethod.__reactBoundContext = component;
|
||||
reboundMethod.__reactBoundMethod = method;
|
||||
reboundMethod.__reactBoundArguments = args;
|
||||
return reboundMethod;
|
||||
};
|
||||
}
|
||||
return boundMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds all auto-bound methods in a component.
|
||||
*
|
||||
* @param {object} component Component whose method is going to be bound.
|
||||
*/
|
||||
function bindAutoBindMethods(component) {
|
||||
var pairs = component.__reactAutoBindPairs;
|
||||
for (var i = 0; i < pairs.length; i += 2) {
|
||||
var autoBindKey = pairs[i];
|
||||
var method = pairs[i + 1];
|
||||
component[autoBindKey] = bindAutoBindMethod(component, method);
|
||||
}
|
||||
}
|
||||
|
||||
var IsMountedPreMixin = {
|
||||
componentDidMount: function() {
|
||||
this.__isMounted = true;
|
||||
}
|
||||
};
|
||||
|
||||
var IsMountedPostMixin = {
|
||||
componentWillUnmount: function() {
|
||||
this.__isMounted = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add more to the ReactClass base class. These are all legacy features and
|
||||
* therefore not already part of the modern ReactComponent.
|
||||
*/
|
||||
var ReactClassMixin = {
|
||||
/**
|
||||
* TODO: This will be deprecated because state should always keep a consistent
|
||||
* type signature and the only use case for this, is to avoid that.
|
||||
*/
|
||||
replaceState: function(newState, callback) {
|
||||
this.updater.enqueueReplaceState(this, newState, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether or not this composite component is mounted.
|
||||
* @return {boolean} True if mounted, false otherwise.
|
||||
* @protected
|
||||
* @final
|
||||
*/
|
||||
isMounted: function() {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(
|
||||
this.__didWarnIsMounted,
|
||||
'%s: isMounted is deprecated. Instead, make sure to clean up ' +
|
||||
'subscriptions and pending requests in componentWillUnmount to ' +
|
||||
'prevent memory leaks.',
|
||||
(this.constructor && this.constructor.displayName) ||
|
||||
this.name ||
|
||||
'Component'
|
||||
);
|
||||
this.__didWarnIsMounted = true;
|
||||
}
|
||||
return !!this.__isMounted;
|
||||
}
|
||||
};
|
||||
|
||||
var ReactClassComponent = function() {};
|
||||
_assign(
|
||||
ReactClassComponent.prototype,
|
||||
ReactComponent.prototype,
|
||||
ReactClassMixin
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates a composite component class given a class specification.
|
||||
* See https://facebook.github.io/react/docs/top-level-api.html#react.createclass
|
||||
*
|
||||
* @param {object} spec Class specification (which must define `render`).
|
||||
* @return {function} Component constructor function.
|
||||
* @public
|
||||
*/
|
||||
function createClass(spec) {
|
||||
// To keep our warnings more understandable, we'll use a little hack here to
|
||||
// ensure that Constructor.name !== 'Constructor'. This makes sure we don't
|
||||
// unnecessarily identify a class without displayName as 'Constructor'.
|
||||
var Constructor = identity(function(props, context, updater) {
|
||||
// This constructor gets overridden by mocks. The argument is used
|
||||
// by mocks to assert on what gets mounted.
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(
|
||||
this instanceof Constructor,
|
||||
'Something is calling a React component directly. Use a factory or ' +
|
||||
'JSX instead. See: https://fb.me/react-legacyfactory'
|
||||
);
|
||||
}
|
||||
|
||||
// Wire up auto-binding
|
||||
if (this.__reactAutoBindPairs.length) {
|
||||
bindAutoBindMethods(this);
|
||||
}
|
||||
|
||||
this.props = props;
|
||||
this.context = context;
|
||||
this.refs = emptyObject;
|
||||
this.updater = updater || ReactNoopUpdateQueue;
|
||||
|
||||
this.state = null;
|
||||
|
||||
// ReactClasses doesn't have constructors. Instead, they use the
|
||||
// getInitialState and componentWillMount methods for initialization.
|
||||
|
||||
var initialState = this.getInitialState ? this.getInitialState() : null;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// We allow auto-mocks to proceed as if they're returning null.
|
||||
if (
|
||||
initialState === undefined &&
|
||||
this.getInitialState._isMockFunction
|
||||
) {
|
||||
// This is probably bad practice. Consider warning here and
|
||||
// deprecating this convenience.
|
||||
initialState = null;
|
||||
}
|
||||
}
|
||||
_invariant(
|
||||
typeof initialState === 'object' && !Array.isArray(initialState),
|
||||
'%s.getInitialState(): must return an object or null',
|
||||
Constructor.displayName || 'ReactCompositeComponent'
|
||||
);
|
||||
|
||||
this.state = initialState;
|
||||
});
|
||||
Constructor.prototype = new ReactClassComponent();
|
||||
Constructor.prototype.constructor = Constructor;
|
||||
Constructor.prototype.__reactAutoBindPairs = [];
|
||||
|
||||
injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
|
||||
|
||||
mixSpecIntoComponent(Constructor, IsMountedPreMixin);
|
||||
mixSpecIntoComponent(Constructor, spec);
|
||||
mixSpecIntoComponent(Constructor, IsMountedPostMixin);
|
||||
|
||||
// Initialize the defaultProps property after all mixins have been merged.
|
||||
if (Constructor.getDefaultProps) {
|
||||
Constructor.defaultProps = Constructor.getDefaultProps();
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// This is a tag to indicate that the use of these method names is ok,
|
||||
// since it's used with createClass. If it's not, then it's likely a
|
||||
// mistake so we'll warn you to use the static property, property
|
||||
// initializer or constructor respectively.
|
||||
if (Constructor.getDefaultProps) {
|
||||
Constructor.getDefaultProps.isReactClassApproved = {};
|
||||
}
|
||||
if (Constructor.prototype.getInitialState) {
|
||||
Constructor.prototype.getInitialState.isReactClassApproved = {};
|
||||
}
|
||||
}
|
||||
|
||||
_invariant(
|
||||
Constructor.prototype.render,
|
||||
'createClass(...): Class specification must implement a `render` method.'
|
||||
);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(
|
||||
!Constructor.prototype.componentShouldUpdate,
|
||||
'%s has a method called ' +
|
||||
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
|
||||
'The name is phrased as a question because the function is ' +
|
||||
'expected to return a value.',
|
||||
spec.displayName || 'A component'
|
||||
);
|
||||
warning(
|
||||
!Constructor.prototype.componentWillRecieveProps,
|
||||
'%s has a method called ' +
|
||||
'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
|
||||
spec.displayName || 'A component'
|
||||
);
|
||||
}
|
||||
|
||||
// Reduce time spent doing lookups by setting these on the prototype.
|
||||
for (var methodName in ReactClassInterface) {
|
||||
if (!Constructor.prototype[methodName]) {
|
||||
Constructor.prototype[methodName] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
return createClass;
|
||||
}
|
||||
|
||||
module.exports = factory;
|
||||
30
addons/create-react-class/index.js
Normal file
30
addons/create-react-class/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var factory = require('./factory');
|
||||
|
||||
if (typeof React === 'undefined') {
|
||||
throw Error(
|
||||
'create-react-class could not find the React object. If you are using script tags, ' +
|
||||
'make sure that React is being loaded before create-react-class.'
|
||||
);
|
||||
}
|
||||
|
||||
// Hack to grab NoopUpdateQueue from isomorphic React
|
||||
var ReactNoopUpdateQueue = new React.Component().updater;
|
||||
|
||||
module.exports = factory(
|
||||
React.Component,
|
||||
React.isValidElement,
|
||||
ReactNoopUpdateQueue
|
||||
);
|
||||
47
addons/create-react-class/package.json
Normal file
47
addons/create-react-class/package.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "create-react-class",
|
||||
"version": "15.6.0",
|
||||
"description": "Legacy API for creating React components.",
|
||||
"main": "index.js",
|
||||
"license": "BSD-3-Clause",
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"factory.js",
|
||||
"index.js",
|
||||
"create-react-class.js",
|
||||
"create-react-class.min.js"
|
||||
],
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/facebook/react/issues"
|
||||
},
|
||||
"homepage": "https://facebook.github.io/react/",
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.9",
|
||||
"loose-envify": "^1.3.1",
|
||||
"object-assign": "^4.1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./create-react-class.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./create-react-class.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^15.5.4",
|
||||
"react-dom": "^15.5.4",
|
||||
"webpack": "^2.6.1"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
"loose-envify"
|
||||
]
|
||||
}
|
||||
}
|
||||
527
addons/create-react-class/test.js
Normal file
527
addons/create-react-class/test.js
Normal file
@@ -0,0 +1,527 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var PropTypes;
|
||||
var React;
|
||||
var ReactDOM;
|
||||
var createReactClass;
|
||||
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.'
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message:
|
||||
'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
// Suppress warning expectations for prod builds
|
||||
function suppressDevMatcher(obj, name) {
|
||||
const original = obj[name];
|
||||
obj[name] = function devMatcher() {
|
||||
try {
|
||||
original.apply(this, arguments);
|
||||
} catch (e) {
|
||||
// skip
|
||||
}
|
||||
};
|
||||
}
|
||||
function expectDev(actual) {
|
||||
const expectation = expect(actual);
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
Object.keys(expectation).forEach(name => {
|
||||
suppressDevMatcher(expectation, name);
|
||||
suppressDevMatcher(expectation.not, name);
|
||||
});
|
||||
}
|
||||
return expectation;
|
||||
}
|
||||
|
||||
function renderIntoDocument(element) {
|
||||
var node = document.createElement('div');
|
||||
return ReactDOM.render(element, node);
|
||||
}
|
||||
|
||||
describe('ReactClass-spec', () => {
|
||||
beforeEach(() => {
|
||||
PropTypes = require('prop-types');
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
createReactClass = require(process.env.TEST_ENTRY);
|
||||
});
|
||||
|
||||
it('should throw when `render` is not specified', () => {
|
||||
expect(function() {
|
||||
createReactClass({});
|
||||
}).toThrowError(
|
||||
'createClass(...): Class specification must implement a `render` method.'
|
||||
);
|
||||
});
|
||||
|
||||
// TODO: Update babel-plugin-transform-react-display-name
|
||||
xit('should copy `displayName` onto the Constructor', () => {
|
||||
var TestComponent = createReactClass({
|
||||
render: function() {
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
|
||||
expect(TestComponent.displayName).toBe('TestComponent');
|
||||
});
|
||||
|
||||
it('should copy prop types onto the Constructor', () => {
|
||||
var propValidator = jest.fn();
|
||||
var TestComponent = createReactClass({
|
||||
propTypes: {
|
||||
value: propValidator
|
||||
},
|
||||
render: function() {
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
|
||||
expect(TestComponent.propTypes).toBeDefined();
|
||||
expect(TestComponent.propTypes.value).toBe(propValidator);
|
||||
});
|
||||
|
||||
it('should warn on invalid prop types', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactClass({
|
||||
displayName: 'Component',
|
||||
propTypes: {
|
||||
prop: null
|
||||
},
|
||||
render: function() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Component: prop type `prop` is invalid; ' +
|
||||
'it must be a function, usually from React.PropTypes.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn on invalid context types', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactClass({
|
||||
displayName: 'Component',
|
||||
contextTypes: {
|
||||
prop: null
|
||||
},
|
||||
render: function() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Component: context type `prop` is invalid; ' +
|
||||
'it must be a function, usually from React.PropTypes.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw on invalid child context types', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactClass({
|
||||
displayName: 'Component',
|
||||
childContextTypes: {
|
||||
prop: null
|
||||
},
|
||||
render: function() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Component: child context type `prop` is invalid; ' +
|
||||
'it must be a function, usually from React.PropTypes.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when mispelling shouldComponentUpdate', () => {
|
||||
spyOn(console, 'error');
|
||||
|
||||
createReactClass({
|
||||
componentShouldUpdate: function() {
|
||||
return false;
|
||||
},
|
||||
render: function() {
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: A component has a method called componentShouldUpdate(). Did you ' +
|
||||
'mean shouldComponentUpdate()? The name is phrased as a question ' +
|
||||
'because the function is expected to return a value.'
|
||||
);
|
||||
|
||||
createReactClass({
|
||||
displayName: 'NamedComponent',
|
||||
componentShouldUpdate: function() {
|
||||
return false;
|
||||
},
|
||||
render: function() {
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(2);
|
||||
expectDev(console.error.calls.argsFor(1)[0]).toBe(
|
||||
'Warning: NamedComponent has a method called componentShouldUpdate(). Did you ' +
|
||||
'mean shouldComponentUpdate()? The name is phrased as a question ' +
|
||||
'because the function is expected to return a value.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when mispelling componentWillReceiveProps', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactClass({
|
||||
componentWillRecieveProps: function() {
|
||||
return false;
|
||||
},
|
||||
render: function() {
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: A component has a method called componentWillRecieveProps(). Did you ' +
|
||||
'mean componentWillReceiveProps()?'
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw if a reserved property is in statics', () => {
|
||||
expect(function() {
|
||||
createReactClass({
|
||||
statics: {
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
foo: 0
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return <span />;
|
||||
}
|
||||
});
|
||||
}).toThrowError(
|
||||
'ReactClass: You are attempting to define a reserved property, ' +
|
||||
'`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' +
|
||||
'it as an instance property instead; it will still be accessible on ' +
|
||||
'the constructor.'
|
||||
);
|
||||
});
|
||||
|
||||
// TODO: Consider actually moving these to statics or drop this unit test.
|
||||
xit('should warn when using deprecated non-static spec keys', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactClass({
|
||||
mixins: [{}],
|
||||
propTypes: {
|
||||
foo: PropTypes.string
|
||||
},
|
||||
contextTypes: {
|
||||
foo: PropTypes.string
|
||||
},
|
||||
childContextTypes: {
|
||||
foo: PropTypes.string
|
||||
},
|
||||
render: function() {
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(4);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'createClass(...): `mixins` is now a static property and should ' +
|
||||
'be defined inside "statics".'
|
||||
);
|
||||
expectDev(console.error.calls.argsFor(1)[0]).toBe(
|
||||
'createClass(...): `propTypes` is now a static property and should ' +
|
||||
'be defined inside "statics".'
|
||||
);
|
||||
expectDev(console.error.calls.argsFor(2)[0]).toBe(
|
||||
'createClass(...): `contextTypes` is now a static property and ' +
|
||||
'should be defined inside "statics".'
|
||||
);
|
||||
expectDev(console.error.calls.argsFor(3)[0]).toBe(
|
||||
'createClass(...): `childContextTypes` is now a static property and ' +
|
||||
'should be defined inside "statics".'
|
||||
);
|
||||
});
|
||||
|
||||
it('should support statics', () => {
|
||||
var Component = createReactClass({
|
||||
statics: {
|
||||
abc: 'def',
|
||||
def: 0,
|
||||
ghi: null,
|
||||
jkl: 'mno',
|
||||
pqr: function() {
|
||||
return this;
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return <span />;
|
||||
}
|
||||
});
|
||||
var instance = <Component />;
|
||||
instance = renderIntoDocument(instance);
|
||||
expect(instance.constructor.abc).toBe('def');
|
||||
expect(Component.abc).toBe('def');
|
||||
expect(instance.constructor.def).toBe(0);
|
||||
expect(Component.def).toBe(0);
|
||||
expect(instance.constructor.ghi).toBe(null);
|
||||
expect(Component.ghi).toBe(null);
|
||||
expect(instance.constructor.jkl).toBe('mno');
|
||||
expect(Component.jkl).toBe('mno');
|
||||
expect(instance.constructor.pqr()).toBe(Component);
|
||||
expect(Component.pqr()).toBe(Component);
|
||||
});
|
||||
|
||||
it('should work with object getInitialState() return values', () => {
|
||||
var Component = createReactClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
occupation: 'clown'
|
||||
};
|
||||
},
|
||||
render: function() {
|
||||
return <span />;
|
||||
}
|
||||
});
|
||||
var instance = <Component />;
|
||||
instance = renderIntoDocument(instance);
|
||||
expect(instance.state.occupation).toEqual('clown');
|
||||
});
|
||||
|
||||
it('renders based on context getInitialState', () => {
|
||||
var Foo = createReactClass({
|
||||
contextTypes: {
|
||||
className: PropTypes.string
|
||||
},
|
||||
getInitialState() {
|
||||
return {className: this.context.className};
|
||||
},
|
||||
render() {
|
||||
return <span className={this.state.className} />;
|
||||
}
|
||||
});
|
||||
|
||||
var Outer = createReactClass({
|
||||
childContextTypes: {
|
||||
className: PropTypes.string
|
||||
},
|
||||
getChildContext() {
|
||||
return {className: 'foo'};
|
||||
},
|
||||
render() {
|
||||
return <Foo />;
|
||||
}
|
||||
});
|
||||
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(<Outer />, container);
|
||||
expect(container.firstChild.className).toBe('foo');
|
||||
});
|
||||
|
||||
it('should throw with non-object getInitialState() return values', () => {
|
||||
spyOn(console, 'error');
|
||||
|
||||
[['an array'], 'a string', 1234].forEach(function(state) {
|
||||
var Component = createReactClass({
|
||||
getInitialState: function() {
|
||||
return state;
|
||||
},
|
||||
render: function() {
|
||||
return <span />;
|
||||
}
|
||||
});
|
||||
var instance = <Component />;
|
||||
expect(function() {
|
||||
instance = renderIntoDocument(instance);
|
||||
}).toThrowError(
|
||||
'Component.getInitialState(): must return an object or null'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with a null getInitialState() return value', () => {
|
||||
var Component = createReactClass({
|
||||
getInitialState: function() {
|
||||
return null;
|
||||
},
|
||||
render: function() {
|
||||
return <span />;
|
||||
}
|
||||
});
|
||||
expect(() => renderIntoDocument(<Component />)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should throw when using legacy factories', () => {
|
||||
spyOn(console, 'error');
|
||||
var Component = createReactClass({
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
|
||||
expect(() => Component()).toThrow();
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Something is calling a React component directly. Use a ' +
|
||||
'factory or JSX instead. See: https://fb.me/react-legacyfactory'
|
||||
);
|
||||
});
|
||||
|
||||
it('replaceState and callback works', () => {
|
||||
var ops = [];
|
||||
var Component = createReactClass({
|
||||
getInitialState() {
|
||||
return {step: 0};
|
||||
},
|
||||
render() {
|
||||
ops.push('Render: ' + this.state.step);
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
|
||||
var instance = renderIntoDocument(<Component />);
|
||||
instance.replaceState({step: 1}, () => {
|
||||
ops.push('Callback: ' + instance.state.step);
|
||||
});
|
||||
expect(ops).toEqual(['Render: 0', 'Render: 1', 'Callback: 1']);
|
||||
});
|
||||
|
||||
it('isMounted works', () => {
|
||||
spyOn(console, 'error');
|
||||
|
||||
var ops = [];
|
||||
var instance;
|
||||
var Component = createReactClass({
|
||||
displayName: 'MyComponent',
|
||||
mixins: [
|
||||
{
|
||||
componentWillMount() {
|
||||
this.log('mixin.componentWillMount');
|
||||
},
|
||||
componentDidMount() {
|
||||
this.log('mixin.componentDidMount');
|
||||
},
|
||||
componentWillUpdate() {
|
||||
this.log('mixin.componentWillUpdate');
|
||||
},
|
||||
componentDidUpdate() {
|
||||
this.log('mixin.componentDidUpdate');
|
||||
},
|
||||
componentWillUnmount() {
|
||||
this.log('mixin.componentWillUnmount');
|
||||
}
|
||||
}
|
||||
],
|
||||
log(name) {
|
||||
ops.push(`${name}: ${this.isMounted()}`);
|
||||
},
|
||||
getInitialState() {
|
||||
this.log('getInitialState');
|
||||
return {};
|
||||
},
|
||||
componentWillMount() {
|
||||
this.log('componentWillMount');
|
||||
},
|
||||
componentDidMount() {
|
||||
this.log('componentDidMount');
|
||||
},
|
||||
componentWillUpdate() {
|
||||
this.log('componentWillUpdate');
|
||||
},
|
||||
componentDidUpdate() {
|
||||
this.log('componentDidUpdate');
|
||||
},
|
||||
componentWillUnmount() {
|
||||
this.log('componentWillUnmount');
|
||||
},
|
||||
render() {
|
||||
instance = this;
|
||||
this.log('render');
|
||||
return <div />;
|
||||
}
|
||||
});
|
||||
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(<Component />, container);
|
||||
ReactDOM.render(<Component />, container);
|
||||
ReactDOM.unmountComponentAtNode(container);
|
||||
instance.log('after unmount');
|
||||
expect(ops).toEqual([
|
||||
'getInitialState: false',
|
||||
'mixin.componentWillMount: false',
|
||||
'componentWillMount: false',
|
||||
'render: false',
|
||||
'mixin.componentDidMount: true',
|
||||
'componentDidMount: true',
|
||||
'mixin.componentWillUpdate: true',
|
||||
'componentWillUpdate: true',
|
||||
'render: true',
|
||||
'mixin.componentDidUpdate: true',
|
||||
'componentDidUpdate: true',
|
||||
'mixin.componentWillUnmount: true',
|
||||
'componentWillUnmount: true',
|
||||
'after unmount: false'
|
||||
]);
|
||||
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toEqual(
|
||||
'Warning: MyComponent: isMounted is deprecated. Instead, make sure to ' +
|
||||
'clean up subscriptions and pending requests in componentWillUnmount ' +
|
||||
'to prevent memory leaks.'
|
||||
);
|
||||
});
|
||||
});
|
||||
61
addons/create-react-class/webpack.config.js
Normal file
61
addons/create-react-class/webpack.config.js
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'createReactClass',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__ ? 'create-react-class.js' : 'create-react-class.min.js'
|
||||
},
|
||||
externals: {
|
||||
react: {
|
||||
root: 'React',
|
||||
commonjs2: 'react',
|
||||
commonjs: 'react',
|
||||
amd: 'react'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"'
|
||||
})
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
})
|
||||
]
|
||||
)
|
||||
};
|
||||
2823
addons/create-react-class/yarn.lock
Normal file
2823
addons/create-react-class/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
73
addons/postbuild.js
Normal file
73
addons/postbuild.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
// This lets us import Webpack config without crashing
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// This script runs from the addon folder
|
||||
var exportName = require(path.resolve(process.cwd(), './webpack.config')).output
|
||||
.library;
|
||||
var packageName = path.basename(process.cwd());
|
||||
|
||||
if (packageName.indexOf('react-addons') !== 0) {
|
||||
throw new Error(
|
||||
'Only run this script for packages that used to be published as addons.'
|
||||
);
|
||||
}
|
||||
|
||||
// Inputs
|
||||
// DEV: root["exportName"] = factory(root["React"])
|
||||
// PROD: e.exportName=t(e.React)
|
||||
var find = new RegExp(
|
||||
'((?!exports)\\b\\w+)(\\["' +
|
||||
exportName +
|
||||
'"\\]|\\.' +
|
||||
exportName +
|
||||
')\\s*=\\s*(\\w+)\\((.*)\\)'
|
||||
);
|
||||
// Outputs
|
||||
// DEV: (root.React ? (root.React.addons = root.React.addons || {}) : /* throw */).exportName = factory(/* ... */);
|
||||
// PROD: (e.React ? (e.React.addons = e.React.addons || {}) : /* throw */).exportName = t(/* ... */)
|
||||
var throwIIFE = [
|
||||
'(function(){',
|
||||
'throw new Error("' +
|
||||
packageName +
|
||||
' could not find the React object. If you are using script tags, make sure that React is being loaded before ' +
|
||||
packageName +
|
||||
'.")',
|
||||
'})()'
|
||||
].join('');
|
||||
var replace =
|
||||
'($1.React?($1.React.addons=$1.React.addons||{}):' +
|
||||
throwIIFE +
|
||||
').' +
|
||||
exportName +
|
||||
'=$3($4)';
|
||||
|
||||
console.log('Tweaking the development UMD...');
|
||||
var devUMD = fs.readFileSync('./' + packageName + '.js', 'utf8').toString();
|
||||
devUMD = devUMD.replace(find, replace);
|
||||
fs.writeFileSync('./' + packageName + '.js', devUMD);
|
||||
|
||||
console.log('Tweaking the production UMD...');
|
||||
var prodUMD = fs
|
||||
.readFileSync('./' + packageName + '.min.js', 'utf8')
|
||||
.toString();
|
||||
prodUMD = prodUMD.replace(find, replace);
|
||||
fs.writeFileSync('./' + packageName + '.min.js', prodUMD);
|
||||
|
||||
console.log('Done.');
|
||||
console.log('Note that you need to manually test the UMD builds.');
|
||||
2
addons/react-addons-create-fragment/.gitignore
vendored
Normal file
2
addons/react-addons-create-fragment/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
react-addons-create-fragment.js
|
||||
react-addons-create-fragment.min.js
|
||||
31
addons/react-addons-create-fragment/LICENSE
Normal file
31
addons/react-addons-create-fragment/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-create-fragment/PATENTS
Normal file
33
addons/react-addons-create-fragment/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
77
addons/react-addons-create-fragment/README.md
Normal file
77
addons/react-addons-create-fragment/README.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# react-addons-create-fragment
|
||||
|
||||
|
||||
>**Note:**
|
||||
>This is a legacy React addon, and is no longer maintained.
|
||||
>
|
||||
>We don't encourage using it in new code, but it exists for backwards compatibility.
|
||||
>The recommended migration path is to use arrays with explicit keys on individual elements.
|
||||
|
||||
**Importing**
|
||||
|
||||
```javascript
|
||||
import createFragment from 'react-addons-create-fragment'; // ES6
|
||||
var createFragment = require('react-addons-create-fragment'); // ES5 with npm
|
||||
```
|
||||
|
||||
If you prefer a `<script>` tag, you can get it from `React.addons.createFragment` with:
|
||||
|
||||
```html
|
||||
<!-- development version -->
|
||||
<script src="https://unpkg.com/react-addons-create-fragment/react-addons-create-fragment.js"></script>
|
||||
|
||||
<!-- production version -->
|
||||
<script src="https://unpkg.com/react-addons-create-fragment/react-addons-create-fragment.min.js"></script>
|
||||
```
|
||||
|
||||
In this case, make sure to put the `<script>` tag after React.
|
||||
|
||||
## Overview
|
||||
|
||||
In most cases, you can use the `key` prop to specify keys on the elements you're returning from `render`. However, this breaks down in one situation: if you have two sets of children that you need to reorder, there's no way to put a key on each set without adding a wrapper element.
|
||||
|
||||
That is, if you have a component such as:
|
||||
|
||||
```js
|
||||
function Swapper(props) {
|
||||
let children;
|
||||
if (props.swapped) {
|
||||
children = [props.rightChildren, props.leftChildren];
|
||||
} else {
|
||||
children = [props.leftChildren, props.rightChildren];
|
||||
}
|
||||
return <div>{children}</div>;
|
||||
}
|
||||
```
|
||||
|
||||
The children will unmount and remount as you change the `swapped` prop because there aren't any keys marked on the two sets of children.
|
||||
|
||||
To solve this problem, you can use the `createFragment` add-on to give keys to the sets of children.
|
||||
|
||||
#### `Array<ReactNode> createFragment(object children)`
|
||||
|
||||
Instead of creating arrays, we write:
|
||||
|
||||
```javascript
|
||||
import createFragment from 'react-addons-create-fragment';
|
||||
|
||||
function Swapper(props) {
|
||||
let children;
|
||||
if (props.swapped) {
|
||||
children = createFragment({
|
||||
right: props.rightChildren,
|
||||
left: props.leftChildren
|
||||
});
|
||||
} else {
|
||||
children = createFragment({
|
||||
left: props.leftChildren,
|
||||
right: props.rightChildren
|
||||
});
|
||||
}
|
||||
return <div>{children}</div>;
|
||||
}
|
||||
```
|
||||
|
||||
The keys of the passed object (that is, `left` and `right`) are used as keys for the entire set of children, and the order of the object's keys is used to determine the order of the rendered children. With this change, the two sets of children will be properly reordered in the DOM without unmounting.
|
||||
|
||||
The return value of `createFragment` should be treated as an opaque object; you can use the [`React.Children`](https://facebook.github.io/react/docs/react-api.html#react.children) helpers to loop through a fragment but should not access it directly. Note also that we're relying on the JavaScript engine preserving object enumeration order here, which is not guaranteed by the spec but is implemented by all major browsers and VMs for objects with non-numeric keys.
|
||||
348
addons/react-addons-create-fragment/index.js
vendored
Normal file
348
addons/react-addons-create-fragment/index.js
vendored
Normal file
@@ -0,0 +1,348 @@
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
var REACT_ELEMENT_TYPE =
|
||||
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) ||
|
||||
0xeac7;
|
||||
|
||||
var emptyFunction = require('fbjs/lib/emptyFunction');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
var SEPARATOR = '.';
|
||||
var SUBSEPARATOR = ':';
|
||||
|
||||
var didWarnAboutMaps = false;
|
||||
|
||||
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
||||
|
||||
function getIteratorFn(maybeIterable) {
|
||||
var iteratorFn =
|
||||
maybeIterable &&
|
||||
((ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL]) ||
|
||||
maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
||||
if (typeof iteratorFn === 'function') {
|
||||
return iteratorFn;
|
||||
}
|
||||
}
|
||||
|
||||
function escape(key) {
|
||||
var escapeRegex = /[=:]/g;
|
||||
var escaperLookup = {
|
||||
'=': '=0',
|
||||
':': '=2'
|
||||
};
|
||||
var escapedString = ('' + key).replace(escapeRegex, function(match) {
|
||||
return escaperLookup[match];
|
||||
});
|
||||
|
||||
return '$' + escapedString;
|
||||
}
|
||||
|
||||
function getComponentKey(component, index) {
|
||||
// Do some typechecking here since we call this blindly. We want to ensure
|
||||
// that we don't block potential future ES APIs.
|
||||
if (component && typeof component === 'object' && component.key != null) {
|
||||
// Explicit key
|
||||
return escape(component.key);
|
||||
}
|
||||
// Implicit key determined by the index in the set
|
||||
return index.toString(36);
|
||||
}
|
||||
|
||||
function traverseAllChildrenImpl(
|
||||
children,
|
||||
nameSoFar,
|
||||
callback,
|
||||
traverseContext
|
||||
) {
|
||||
var type = typeof children;
|
||||
|
||||
if (type === 'undefined' || type === 'boolean') {
|
||||
// All of the above are perceived as null.
|
||||
children = null;
|
||||
}
|
||||
|
||||
if (
|
||||
children === null ||
|
||||
type === 'string' ||
|
||||
type === 'number' ||
|
||||
// The following is inlined from ReactElement. This means we can optimize
|
||||
// some checks. React Fiber also inlines this logic for similar purposes.
|
||||
(type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE)
|
||||
) {
|
||||
callback(
|
||||
traverseContext,
|
||||
children,
|
||||
// If it's the only child, treat the name as if it was wrapped in an array
|
||||
// so that it's consistent if the number of children grows.
|
||||
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
var child;
|
||||
var nextName;
|
||||
var subtreeCount = 0; // Count of children found in the current subtree.
|
||||
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
||||
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
child = children[i];
|
||||
nextName = nextNamePrefix + getComponentKey(child, i);
|
||||
subtreeCount += traverseAllChildrenImpl(
|
||||
child,
|
||||
nextName,
|
||||
callback,
|
||||
traverseContext
|
||||
);
|
||||
}
|
||||
} else {
|
||||
var iteratorFn = getIteratorFn(children);
|
||||
if (iteratorFn) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// Warn about using Maps as children
|
||||
if (iteratorFn === children.entries) {
|
||||
warning(
|
||||
didWarnAboutMaps,
|
||||
'Using Maps as children is unsupported and will likely yield ' +
|
||||
'unexpected results. Convert it to a sequence/iterable of keyed ' +
|
||||
'ReactElements instead.'
|
||||
);
|
||||
didWarnAboutMaps = true;
|
||||
}
|
||||
}
|
||||
|
||||
var iterator = iteratorFn.call(children);
|
||||
var step;
|
||||
var ii = 0;
|
||||
while (!(step = iterator.next()).done) {
|
||||
child = step.value;
|
||||
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
||||
subtreeCount += traverseAllChildrenImpl(
|
||||
child,
|
||||
nextName,
|
||||
callback,
|
||||
traverseContext
|
||||
);
|
||||
}
|
||||
} else if (type === 'object') {
|
||||
var addendum = '';
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
addendum =
|
||||
' If you meant to render a collection of children, use an array ' +
|
||||
'instead or wrap the object using createFragment(object) from the ' +
|
||||
'React add-ons.';
|
||||
}
|
||||
var childrenString = '' + children;
|
||||
invariant(
|
||||
false,
|
||||
'Objects are not valid as a React child (found: %s).%s',
|
||||
childrenString === '[object Object]'
|
||||
? 'object with keys {' + Object.keys(children).join(', ') + '}'
|
||||
: childrenString,
|
||||
addendum
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return subtreeCount;
|
||||
}
|
||||
|
||||
function traverseAllChildren(children, callback, traverseContext) {
|
||||
if (children == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return traverseAllChildrenImpl(children, '', callback, traverseContext);
|
||||
}
|
||||
|
||||
var userProvidedKeyEscapeRegex = /\/+/g;
|
||||
function escapeUserProvidedKey(text) {
|
||||
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
||||
}
|
||||
|
||||
function cloneAndReplaceKey(oldElement, newKey) {
|
||||
return React.cloneElement(
|
||||
oldElement,
|
||||
{key: newKey},
|
||||
oldElement.props !== undefined ? oldElement.props.children : undefined
|
||||
);
|
||||
}
|
||||
|
||||
var DEFAULT_POOL_SIZE = 10;
|
||||
var DEFAULT_POOLER = oneArgumentPooler;
|
||||
|
||||
var oneArgumentPooler = function(copyFieldsFrom) {
|
||||
var Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, copyFieldsFrom);
|
||||
return instance;
|
||||
} else {
|
||||
return new Klass(copyFieldsFrom);
|
||||
}
|
||||
};
|
||||
|
||||
var addPoolingTo = function addPoolingTo(CopyConstructor, pooler) {
|
||||
// Casting as any so that flow ignores the actual implementation and trusts
|
||||
// it to match the type we declared
|
||||
var NewKlass = CopyConstructor;
|
||||
NewKlass.instancePool = [];
|
||||
NewKlass.getPooled = pooler || DEFAULT_POOLER;
|
||||
if (!NewKlass.poolSize) {
|
||||
NewKlass.poolSize = DEFAULT_POOL_SIZE;
|
||||
}
|
||||
NewKlass.release = standardReleaser;
|
||||
return NewKlass;
|
||||
};
|
||||
|
||||
var standardReleaser = function standardReleaser(instance) {
|
||||
var Klass = this;
|
||||
invariant(
|
||||
instance instanceof Klass,
|
||||
'Trying to release an instance into a pool of a different type.'
|
||||
);
|
||||
instance.destructor();
|
||||
if (Klass.instancePool.length < Klass.poolSize) {
|
||||
Klass.instancePool.push(instance);
|
||||
}
|
||||
};
|
||||
|
||||
var fourArgumentPooler = function fourArgumentPooler(a1, a2, a3, a4) {
|
||||
var Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2, a3, a4);
|
||||
return instance;
|
||||
} else {
|
||||
return new Klass(a1, a2, a3, a4);
|
||||
}
|
||||
};
|
||||
|
||||
function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
|
||||
this.result = mapResult;
|
||||
this.keyPrefix = keyPrefix;
|
||||
this.func = mapFunction;
|
||||
this.context = mapContext;
|
||||
this.count = 0;
|
||||
}
|
||||
MapBookKeeping.prototype.destructor = function() {
|
||||
this.result = null;
|
||||
this.keyPrefix = null;
|
||||
this.func = null;
|
||||
this.context = null;
|
||||
this.count = 0;
|
||||
};
|
||||
addPoolingTo(MapBookKeeping, fourArgumentPooler);
|
||||
|
||||
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
||||
var result = bookKeeping.result;
|
||||
var keyPrefix = bookKeeping.keyPrefix;
|
||||
var func = bookKeeping.func;
|
||||
var context = bookKeeping.context;
|
||||
|
||||
var mappedChild = func.call(context, child, bookKeeping.count++);
|
||||
if (Array.isArray(mappedChild)) {
|
||||
mapIntoWithKeyPrefixInternal(
|
||||
mappedChild,
|
||||
result,
|
||||
childKey,
|
||||
emptyFunction.thatReturnsArgument
|
||||
);
|
||||
} else if (mappedChild != null) {
|
||||
if (React.isValidElement(mappedChild)) {
|
||||
mappedChild = cloneAndReplaceKey(
|
||||
mappedChild,
|
||||
// Keep both the (mapped) and old keys if they differ, just as
|
||||
// traverseAllChildren used to do for objects as children
|
||||
keyPrefix +
|
||||
(mappedChild.key && (!child || child.key !== mappedChild.key)
|
||||
? escapeUserProvidedKey(mappedChild.key) + '/'
|
||||
: '') +
|
||||
childKey
|
||||
);
|
||||
}
|
||||
result.push(mappedChild);
|
||||
}
|
||||
}
|
||||
|
||||
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
||||
var escapedPrefix = '';
|
||||
if (prefix != null) {
|
||||
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
||||
}
|
||||
var traverseContext = MapBookKeeping.getPooled(
|
||||
array,
|
||||
escapedPrefix,
|
||||
func,
|
||||
context
|
||||
);
|
||||
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
||||
MapBookKeeping.release(traverseContext);
|
||||
}
|
||||
|
||||
var numericPropertyRegex = /^\d+$/;
|
||||
|
||||
var warnedAboutNumeric = false;
|
||||
|
||||
function createReactFragment(object) {
|
||||
if (typeof object !== 'object' || !object || Array.isArray(object)) {
|
||||
warning(
|
||||
false,
|
||||
'React.addons.createFragment only accepts a single object. Got: %s',
|
||||
object
|
||||
);
|
||||
return object;
|
||||
}
|
||||
if (React.isValidElement(object)) {
|
||||
warning(
|
||||
false,
|
||||
'React.addons.createFragment does not accept a ReactElement ' +
|
||||
'without a wrapper object.'
|
||||
);
|
||||
return object;
|
||||
}
|
||||
|
||||
invariant(
|
||||
object.nodeType !== 1,
|
||||
'React.addons.createFragment(...): Encountered an invalid child; DOM ' +
|
||||
'elements are not valid children of React components.'
|
||||
);
|
||||
|
||||
var result = [];
|
||||
|
||||
for (var key in object) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!warnedAboutNumeric && numericPropertyRegex.test(key)) {
|
||||
warning(
|
||||
false,
|
||||
'React.addons.createFragment(...): Child objects should have ' +
|
||||
'non-numeric keys so ordering is preserved.'
|
||||
);
|
||||
warnedAboutNumeric = true;
|
||||
}
|
||||
}
|
||||
mapIntoWithKeyPrefixInternal(
|
||||
object[key],
|
||||
result,
|
||||
key,
|
||||
emptyFunction.thatReturnsArgument
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = createReactFragment;
|
||||
42
addons/react-addons-create-fragment/package.json
Normal file
42
addons/react-addons-create-fragment/package.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "react-addons-create-fragment",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.4",
|
||||
"loose-envify": "^1.3.1",
|
||||
"object-assign": "^4.1.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js",
|
||||
"react-addons-create-fragment.js",
|
||||
"react-addons-create-fragment.min.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./react-addons-create-fragment.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./react-addons-create-fragment.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod && node ../postbuild.js",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.4.2",
|
||||
"react-dom": "^15.4.2",
|
||||
"webpack": "^2.6.1"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
"loose-envify"
|
||||
]
|
||||
}
|
||||
}
|
||||
133
addons/react-addons-create-fragment/test.js
vendored
Normal file
133
addons/react-addons-create-fragment/test.js
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var createReactFragment;
|
||||
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.'
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message:
|
||||
'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
// Suppress warning expectations for prod builds
|
||||
function suppressDevMatcher(obj, name) {
|
||||
const original = obj[name];
|
||||
obj[name] = function devMatcher() {
|
||||
try {
|
||||
original.apply(this, arguments);
|
||||
} catch (e) {
|
||||
// skip
|
||||
}
|
||||
};
|
||||
}
|
||||
function expectDev(actual) {
|
||||
const expectation = expect(actual);
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
Object.keys(expectation).forEach(name => {
|
||||
suppressDevMatcher(expectation, name);
|
||||
suppressDevMatcher(expectation.not, name);
|
||||
});
|
||||
}
|
||||
return expectation;
|
||||
}
|
||||
|
||||
describe('createReactFragment', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
|
||||
React = require('react');
|
||||
createReactFragment = require(process.env.TEST_ENTRY);
|
||||
});
|
||||
|
||||
it('warns for numeric keys on objects as children', () => {
|
||||
spyOn(console, 'error');
|
||||
|
||||
createReactFragment({
|
||||
1: React.createElement('span'),
|
||||
2: React.createElement('span')
|
||||
});
|
||||
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'Child objects should have non-numeric keys so ordering is preserved.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if passing null to createFragment', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactFragment(null);
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'React.addons.createFragment only accepts a single object.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if passing an array to createFragment', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactFragment([]);
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'React.addons.createFragment only accepts a single object.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if passing a ReactElement to createFragment', () => {
|
||||
spyOn(console, 'error');
|
||||
createReactFragment(React.createElement('div'));
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'React.addons.createFragment does not accept a ReactElement without a ' +
|
||||
'wrapper object.'
|
||||
);
|
||||
});
|
||||
});
|
||||
63
addons/react-addons-create-fragment/webpack.config.js
Normal file
63
addons/react-addons-create-fragment/webpack.config.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'createFragment',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__
|
||||
? 'react-addons-create-fragment.js'
|
||||
: 'react-addons-create-fragment.min.js'
|
||||
},
|
||||
externals: {
|
||||
react: {
|
||||
root: 'React',
|
||||
commonjs2: 'react',
|
||||
commonjs: 'react',
|
||||
amd: 'react'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"'
|
||||
})
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
})
|
||||
]
|
||||
)
|
||||
};
|
||||
2827
addons/react-addons-create-fragment/yarn.lock
Normal file
2827
addons/react-addons-create-fragment/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
31
addons/react-addons-css-transition-group/LICENSE
Normal file
31
addons/react-addons-css-transition-group/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-css-transition-group/PATENTS
Normal file
33
addons/react-addons-css-transition-group/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
17
addons/react-addons-css-transition-group/README.md
Normal file
17
addons/react-addons-css-transition-group/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# react-addons-css-transition-group
|
||||
|
||||
The code in this package has moved. We recommend you to use `CSSTransitionGroup` from [`react-transition-group`](https://github.com/reactjs/react-transition-group) instead.
|
||||
|
||||
In particular, its version `1.x` is a drop-in replacement for the last released version of `react-addons-css-transition-group`.
|
||||
|
||||
Run `npm install --save react-transition-group@1.x`, and replace the imports in your code:
|
||||
|
||||
```js
|
||||
// Old
|
||||
import CSSTransitionGroup from 'react-addons-css-transition-group';
|
||||
|
||||
// New
|
||||
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup';
|
||||
```
|
||||
|
||||
The documentation branch for `react-transition-group@1.x` [can be found here](https://github.com/reactjs/react-transition-group/tree/v1-stable#high-level-api-csstransitiongroup).
|
||||
12
addons/react-addons-css-transition-group/index.js
vendored
Normal file
12
addons/react-addons-css-transition-group/index.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = require('react-transition-group/CSSTransitionGroup');
|
||||
26
addons/react-addons-css-transition-group/package.json
Normal file
26
addons/react-addons-css-transition-group/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "react-addons-css-transition-group",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"prepublish": ":"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-transition-group": "^1.2.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"react": "^15.4.2"
|
||||
}
|
||||
}
|
||||
114
addons/react-addons-css-transition-group/yarn.lock
Normal file
114
addons/react-addons-css-transition-group/yarn.lock
Normal file
@@ -0,0 +1,114 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
asap@~2.0.3:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f"
|
||||
|
||||
chain-function@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/chain-function/-/chain-function-1.0.0.tgz#0d4ab37e7e18ead0bdc47b920764118ce58733dc"
|
||||
|
||||
core-js@^1.0.0:
|
||||
version "1.2.7"
|
||||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
|
||||
|
||||
dom-helpers@^3.2.0:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.2.1.tgz#3203e07fed217bd1f424b019735582fc37b2825a"
|
||||
|
||||
encoding@^0.1.11:
|
||||
version "0.1.12"
|
||||
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
|
||||
dependencies:
|
||||
iconv-lite "~0.4.13"
|
||||
|
||||
fbjs@^0.8.9:
|
||||
version "0.8.12"
|
||||
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04"
|
||||
dependencies:
|
||||
core-js "^1.0.0"
|
||||
isomorphic-fetch "^2.1.1"
|
||||
loose-envify "^1.0.0"
|
||||
object-assign "^4.1.0"
|
||||
promise "^7.1.1"
|
||||
setimmediate "^1.0.5"
|
||||
ua-parser-js "^0.7.9"
|
||||
|
||||
iconv-lite@~0.4.13:
|
||||
version "0.4.17"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.17.tgz#4fdaa3b38acbc2c031b045d0edcdfe1ecab18c8d"
|
||||
|
||||
is-stream@^1.0.1:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
|
||||
|
||||
isomorphic-fetch@^2.1.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
|
||||
dependencies:
|
||||
node-fetch "^1.0.1"
|
||||
whatwg-fetch ">=0.10.0"
|
||||
|
||||
js-tokens@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"
|
||||
|
||||
loose-envify@^1.0.0, loose-envify@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
|
||||
dependencies:
|
||||
js-tokens "^3.0.0"
|
||||
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5"
|
||||
dependencies:
|
||||
encoding "^0.1.11"
|
||||
is-stream "^1.0.1"
|
||||
|
||||
object-assign@^4.1.0:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
|
||||
promise@^7.1.1:
|
||||
version "7.1.1"
|
||||
resolved "https://registry.yarnpkg.com/promise/-/promise-7.1.1.tgz#489654c692616b8aa55b0724fa809bb7db49c5bf"
|
||||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
prop-types@^15.5.6:
|
||||
version "15.5.10"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
|
||||
dependencies:
|
||||
fbjs "^0.8.9"
|
||||
loose-envify "^1.3.1"
|
||||
|
||||
react-transition-group@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-1.2.0.tgz#b51fc921b0c3835a7ef7c571c79fc82c73e9204f"
|
||||
dependencies:
|
||||
chain-function "^1.0.0"
|
||||
dom-helpers "^3.2.0"
|
||||
loose-envify "^1.3.1"
|
||||
prop-types "^15.5.6"
|
||||
warning "^3.0.0"
|
||||
|
||||
setimmediate@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
|
||||
|
||||
ua-parser-js@^0.7.9:
|
||||
version "0.7.12"
|
||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"
|
||||
|
||||
warning@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"
|
||||
dependencies:
|
||||
loose-envify "^1.0.0"
|
||||
|
||||
whatwg-fetch@>=0.10.0:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
|
||||
2
addons/react-addons-linked-state-mixin/.gitignore
vendored
Normal file
2
addons/react-addons-linked-state-mixin/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
react-addons-linked-state-mixin.js
|
||||
react-addons-linked-state-mixin.min.js
|
||||
31
addons/react-addons-linked-state-mixin/LICENSE
Normal file
31
addons/react-addons-linked-state-mixin/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-linked-state-mixin/PATENTS
Normal file
33
addons/react-addons-linked-state-mixin/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
109
addons/react-addons-linked-state-mixin/README.md
Normal file
109
addons/react-addons-linked-state-mixin/README.md
Normal file
@@ -0,0 +1,109 @@
|
||||
# react-addons-linked-state-mixin
|
||||
|
||||
>**Note:**
|
||||
>This is a legacy React addon, and is no longer maintained.
|
||||
>
|
||||
>We don't encourage using it in new code, but it exists for backwards compatibility.
|
||||
>The recommended migration path is to explicitly set `value` and the `onChange` handler instead of using `LinkedStateMixin`.
|
||||
|
||||
**Importing `LinkedStateMixin`**
|
||||
|
||||
```javascript
|
||||
import LinkedStateMixin from 'react-addons-linked-state-mixin'; // ES6
|
||||
var LinkedStateMixin = require('react-addons-linked-state-mixin'); // ES5 with npm
|
||||
```
|
||||
|
||||
If you prefer a `<script>` tag, you can get it from `React.addons.LinkedStateMixin` with:
|
||||
|
||||
```html
|
||||
<!-- development version -->
|
||||
<script src="https://unpkg.com/react-addons-linked-state-mixin/react-addons-linked-state-mixin.js"></script>
|
||||
|
||||
<!-- production version -->
|
||||
<script src="https://unpkg.com/react-addons-linked-state-mixin/react-addons-linked-state-mixin.min.js"></script>
|
||||
```
|
||||
|
||||
In this case, make sure to put the `<script>` tag after React.
|
||||
|
||||
**Importing `LinkedInput`**
|
||||
|
||||
After React 16, you will also need `LinkedInput` component if you want to keep using this pattern. You can import it like this:
|
||||
|
||||
```javascript
|
||||
import LinkedInput from 'react-linked-input'; // ES6
|
||||
var LinkedInput = require('react-linked-input'); // ES5 with npm
|
||||
```
|
||||
|
||||
If you prefer a `<script>` tag, you can get it from `LinkedInput` global with:
|
||||
|
||||
```html
|
||||
<!-- development version -->
|
||||
<script src="https://unpkg.com/react-linked-input/react-linked-input.js"></script>
|
||||
|
||||
<!-- production version -->
|
||||
<script src="https://unpkg.com/react-linked-input/react-linked-input.min.js"></script>
|
||||
```
|
||||
|
||||
## Overview
|
||||
|
||||
`LinkedStateMixin` is an easy way to express two-way binding with React.
|
||||
|
||||
In React, data flows one way: from owner to child. We think that this makes your app's code easier to understand. You can think of it as "one-way data binding."
|
||||
|
||||
However, there are lots of applications that require you to read some data and flow it back into your program. For example, when developing forms, you'll often want to update some React `state` when you receive user input. Or perhaps you want to perform layout in JavaScript and react to changes in some DOM element size.
|
||||
|
||||
In React, you would implement this by listening to a "change" event, read from your data source (usually the DOM) and call `setState()` on one of your components. "Closing the data flow loop" explicitly leads to more understandable and easier-to-maintain programs. See [our forms documentation](https://facebook.github.io/react/docs/forms.html) for more information.
|
||||
|
||||
Two-way binding -- implicitly enforcing that some value in the DOM is always consistent with some React `state` -- is concise and supports a wide variety of applications. We've provided `LinkedStateMixin`: syntactic sugar for setting up the common data flow loop pattern described above, or "linking" some data source to React `state`.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> `LinkedStateMixin` is just a thin wrapper and convention around the `onChange`/`setState()` pattern. It doesn't fundamentally change how data flows in your React application.
|
||||
|
||||
## LinkedStateMixin: Before and After
|
||||
|
||||
Here's a simple form example without using `LinkedStateMixin`:
|
||||
|
||||
```javascript
|
||||
var createReactClass = require('create-react-class');
|
||||
|
||||
var NoLink = createReactClass({
|
||||
getInitialState: function() {
|
||||
return {message: 'Hello!'};
|
||||
},
|
||||
handleChange: function(event) {
|
||||
this.setState({message: event.target.value});
|
||||
},
|
||||
render: function() {
|
||||
var message = this.state.message;
|
||||
return <input type="text" value={message} onChange={this.handleChange} />;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
This works really well and it's very clear how data is flowing, however, with a lot of form fields it could get a bit verbose. Let's use `LinkedStateMixin` to save us some typing:
|
||||
|
||||
```javascript
|
||||
var createReactClass = require('create-react-class');
|
||||
var LinkedInput = require('react-linked-input');
|
||||
|
||||
var WithLink = createReactClass({
|
||||
mixins: [LinkedStateMixin],
|
||||
getInitialState: function() {
|
||||
return {message: 'Hello!'};
|
||||
},
|
||||
render: function() {
|
||||
return <LinkedInput type="text" valueLink={this.linkState('message')} />;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
`LinkedStateMixin` adds a method to your React component called `linkState()`. `linkState()` returns a `valueLink` object which contains the current value of the React state and a callback to change it. The `LinkInput` component passes those properties to the input it renders.
|
||||
|
||||
`valueLink` objects can be passed up and down the tree as props, so it's easy (and explicit) to set up two-way binding between a component deep in the hierarchy and state that lives higher in the hierarchy.
|
||||
|
||||
Note that checkboxes have a special behavior regarding their `value` attribute, which is the value that will be sent on form submit if the checkbox is checked (defaults to `on`). The `value` attribute is not updated when the checkbox is checked or unchecked. For checkboxes, you should use `checkedLink` instead of `valueLink`:
|
||||
|
||||
```
|
||||
<LinkedInput type="checkbox" checkedLink={this.linkState('booleanValue')} />
|
||||
```
|
||||
158
addons/react-addons-linked-state-mixin/index.js
vendored
Normal file
158
addons/react-addons-linked-state-mixin/index.js
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* ReactLink encapsulates a common pattern in which a component wants to modify
|
||||
* a prop received from its parent. ReactLink allows the parent to pass down a
|
||||
* value coupled with a callback that, when invoked, expresses an intent to
|
||||
* modify that value. For example:
|
||||
*
|
||||
* React.createClass({
|
||||
* getInitialState: function() {
|
||||
* return {value: ''};
|
||||
* },
|
||||
* render: function() {
|
||||
* var valueLink = new ReactLink(this.state.value, this._handleValueChange);
|
||||
* return <input valueLink={valueLink} />;
|
||||
* },
|
||||
* _handleValueChange: function(newValue) {
|
||||
* this.setState({value: newValue});
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* We have provided some sugary mixins to make the creation and
|
||||
* consumption of ReactLink easier; see LinkedValueUtils and LinkedStateMixin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Deprecated: An an easy way to express two-way binding with React.
|
||||
* See https://facebook.github.io/react/docs/two-way-binding-helpers.html
|
||||
*
|
||||
* @param {*} value current value of the link
|
||||
* @param {function} requestChange callback to request a change
|
||||
*/
|
||||
function ReactLink(value, requestChange) {
|
||||
this.value = value;
|
||||
this.requestChange = requestChange;
|
||||
}
|
||||
|
||||
var ReactStateSetters = {
|
||||
/**
|
||||
* Returns a function that calls the provided function, and uses the result
|
||||
* of that to set the component's state.
|
||||
*
|
||||
* @param {ReactCompositeComponent} component
|
||||
* @param {function} funcReturningState Returned callback uses this to
|
||||
* determine how to update state.
|
||||
* @return {function} callback that when invoked uses funcReturningState to
|
||||
* determined the object literal to setState.
|
||||
*/
|
||||
createStateSetter: function(component, funcReturningState) {
|
||||
return function(a, b, c, d, e, f) {
|
||||
var partialState = funcReturningState.call(component, a, b, c, d, e, f);
|
||||
if (partialState) {
|
||||
component.setState(partialState);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a single-argument callback that can be used to update a single
|
||||
* key in the component's state.
|
||||
*
|
||||
* Note: this is memoized function, which makes it inexpensive to call.
|
||||
*
|
||||
* @param {ReactCompositeComponent} component
|
||||
* @param {string} key The key in the state that you should update.
|
||||
* @return {function} callback of 1 argument which calls setState() with
|
||||
* the provided keyName and callback argument.
|
||||
*/
|
||||
createStateKeySetter: function(component, key) {
|
||||
// Memoize the setters.
|
||||
var cache = component.__keySetters || (component.__keySetters = {});
|
||||
return cache[key] || (cache[key] = createStateKeySetter(component, key));
|
||||
}
|
||||
};
|
||||
|
||||
function createStateKeySetter(component, key) {
|
||||
// Partial state is allocated outside of the function closure so it can be
|
||||
// reused with every call, avoiding memory allocation when this function
|
||||
// is called.
|
||||
var partialState = {};
|
||||
return function stateKeySetter(value) {
|
||||
partialState[key] = value;
|
||||
component.setState(partialState);
|
||||
};
|
||||
}
|
||||
|
||||
ReactStateSetters.Mixin = {
|
||||
/**
|
||||
* Returns a function that calls the provided function, and uses the result
|
||||
* of that to set the component's state.
|
||||
*
|
||||
* For example, these statements are equivalent:
|
||||
*
|
||||
* this.setState({x: 1});
|
||||
* this.createStateSetter(function(xValue) {
|
||||
* return {x: xValue};
|
||||
* })(1);
|
||||
*
|
||||
* @param {function} funcReturningState Returned callback uses this to
|
||||
* determine how to update state.
|
||||
* @return {function} callback that when invoked uses funcReturningState to
|
||||
* determined the object literal to setState.
|
||||
*/
|
||||
createStateSetter: function(funcReturningState) {
|
||||
return ReactStateSetters.createStateSetter(this, funcReturningState);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a single-argument callback that can be used to update a single
|
||||
* key in the component's state.
|
||||
*
|
||||
* For example, these statements are equivalent:
|
||||
*
|
||||
* this.setState({x: 1});
|
||||
* this.createStateKeySetter('x')(1);
|
||||
*
|
||||
* Note: this is memoized function, which makes it inexpensive to call.
|
||||
*
|
||||
* @param {string} key The key in the state that you should update.
|
||||
* @return {function} callback of 1 argument which calls setState() with
|
||||
* the provided keyName and callback argument.
|
||||
*/
|
||||
createStateKeySetter: function(key) {
|
||||
return ReactStateSetters.createStateKeySetter(this, key);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A simple mixin around ReactLink.forState().
|
||||
* See https://facebook.github.io/react/docs/two-way-binding-helpers.html
|
||||
*/
|
||||
var LinkedStateMixin = {
|
||||
/**
|
||||
* Create a ReactLink that's linked to part of this component's state. The
|
||||
* ReactLink will have the current value of this.state[key] and will call
|
||||
* setState() when a change is requested.
|
||||
*
|
||||
* @param {string} key state key to update.
|
||||
* @return {ReactLink} ReactLink instance linking to the state.
|
||||
*/
|
||||
linkState: function(key) {
|
||||
return new ReactLink(
|
||||
this.state[key],
|
||||
ReactStateSetters.createStateKeySetter(this, key)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = LinkedStateMixin;
|
||||
37
addons/react-addons-linked-state-mixin/package.json
Normal file
37
addons/react-addons-linked-state-mixin/package.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "react-addons-linked-state-mixin",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.4",
|
||||
"object-assign": "^4.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./react-addons-linked-state-mixin.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./react-addons-linked-state-mixin.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod && node ../postbuild.js",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js",
|
||||
"react-addons-linked-state-mixin.js",
|
||||
"react-addons-linked-state-mixin.min.js"
|
||||
],
|
||||
"devDependencies": {
|
||||
"create-react-class": "^15.5.4",
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.5.4",
|
||||
"react-dom": "^15.5.4",
|
||||
"webpack": "^2.6.1"
|
||||
}
|
||||
}
|
||||
133
addons/react-addons-linked-state-mixin/test.js
vendored
Normal file
133
addons/react-addons-linked-state-mixin/test.js
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
let LinkedStateMixin;
|
||||
let createReactClass;
|
||||
let React;
|
||||
let ReactDOM;
|
||||
let ReactTestUtils;
|
||||
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.'
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message:
|
||||
'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('LinkedStateMixin', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
|
||||
createReactClass = require('create-react-class');
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactTestUtils = require('react-dom/test-utils');
|
||||
LinkedStateMixin = require(process.env.TEST_ENTRY);
|
||||
});
|
||||
|
||||
// https://facebook.github.io/react/docs/two-way-binding-helpers.html#linkedstatemixin-before-and-after
|
||||
it('should work with valueLink', () => {
|
||||
spyOn(console, 'error'); // Ignore deprecated valueLink message for now
|
||||
|
||||
const WithLink = createReactClass({
|
||||
mixins: [LinkedStateMixin],
|
||||
getInitialState: function() {
|
||||
return {message: 'Hello!'};
|
||||
},
|
||||
render: function() {
|
||||
return <input type="text" valueLink={this.linkState('message')} />;
|
||||
}
|
||||
});
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(WithLink)
|
||||
);
|
||||
|
||||
expect(instance.state.message).toBe('Hello!');
|
||||
|
||||
const node = ReactDOM.findDOMNode(instance);
|
||||
node.value = 'Goodbye!';
|
||||
ReactTestUtils.Simulate.change(node);
|
||||
|
||||
expect(instance.state.message).toBe('Goodbye!');
|
||||
});
|
||||
|
||||
// https://facebook.github.io/react/docs/two-way-binding-helpers.html#linkedstatemixin-without-valuelink
|
||||
it('should work without valueLink', () => {
|
||||
const WithoutLink = createReactClass({
|
||||
mixins: [LinkedStateMixin],
|
||||
getInitialState: function() {
|
||||
return {message: 'Hello!'};
|
||||
},
|
||||
render: function() {
|
||||
var valueLink = this.linkState('message');
|
||||
var handleChange = function(e) {
|
||||
valueLink.requestChange(e.target.value);
|
||||
};
|
||||
return (
|
||||
<input type="text" value={valueLink.value} onChange={handleChange} />
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(WithoutLink)
|
||||
);
|
||||
|
||||
expect(instance.state.message).toBe('Hello!');
|
||||
|
||||
const node = ReactDOM.findDOMNode(instance);
|
||||
node.value = 'Goodbye!';
|
||||
ReactTestUtils.Simulate.change(node);
|
||||
|
||||
expect(instance.state.message).toBe('Goodbye!');
|
||||
});
|
||||
});
|
||||
55
addons/react-addons-linked-state-mixin/webpack.config.js
Normal file
55
addons/react-addons-linked-state-mixin/webpack.config.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'LinkedStateMixin',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__
|
||||
? 'react-addons-linked-state-mixin.js'
|
||||
: 'react-addons-linked-state-mixin.min.js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"'
|
||||
})
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
})
|
||||
]
|
||||
)
|
||||
};
|
||||
2831
addons/react-addons-linked-state-mixin/yarn.lock
Normal file
2831
addons/react-addons-linked-state-mixin/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
2
addons/react-addons-pure-render-mixin/.gitignore
vendored
Normal file
2
addons/react-addons-pure-render-mixin/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
react-addons-pure-render-mixin.js
|
||||
react-addons-pure-render-mixin.min.js
|
||||
31
addons/react-addons-pure-render-mixin/LICENSE
Normal file
31
addons/react-addons-pure-render-mixin/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-pure-render-mixin/PATENTS
Normal file
33
addons/react-addons-pure-render-mixin/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
52
addons/react-addons-pure-render-mixin/README.md
Normal file
52
addons/react-addons-pure-render-mixin/README.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# react-addons-pure-render-mixin
|
||||
|
||||
>**Note:**
|
||||
>This is a legacy React addon, and is no longer maintained.
|
||||
>
|
||||
>We don't encourage using it in new code, but it exists for backwards compatibility.
|
||||
>The recommended migration path is to use [`React.PureComponent`](https://facebook.github.io/react/docs/react-api.html#react.purecomponent) instead.
|
||||
|
||||
**Importing**
|
||||
|
||||
```javascript
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin'; // ES6
|
||||
var PureRenderMixin = require('react-addons-pure-render-mixin'); // ES5 with npm
|
||||
```
|
||||
|
||||
If you prefer a `<script>` tag, you can get it from `React.addons.PureRenderMixin` with:
|
||||
|
||||
```html
|
||||
<!-- development version -->
|
||||
<script src="https://unpkg.com/react-addons-pure-render-mixin/react-addons-pure-render-mixin.js"></script>
|
||||
|
||||
<!-- production version -->
|
||||
<script src="https://unpkg.com/react-addons-pure-render-mixin/react-addons-pure-render-mixin.min.js"></script>
|
||||
```
|
||||
|
||||
In this case, make sure to put the `<script>` tag after React.
|
||||
|
||||
## Overview
|
||||
|
||||
If your React component's render function renders the same result given the same props and state, you can use this mixin for a performance boost in some cases.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const createReactClass = require('create-react-class');
|
||||
|
||||
createReactClass({
|
||||
mixins: [PureRenderMixin],
|
||||
|
||||
render: function() {
|
||||
return <div className={this.props.className}>foo</div>;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Under the hood, the mixin implements [shouldComponentUpdate](https://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate), in which it compares the current props and state with the next ones and returns `false` if the equalities pass.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> This only shallowly compares the objects. If these contain complex data structures, it may produce false-negatives for deeper differences. Only mix into components which have simple props and state, or use `forceUpdate()` when you know deep data structures have changed. Or, consider using [immutable objects](https://facebook.github.io/immutable-js/) to facilitate fast comparisons of nested data.
|
||||
>
|
||||
> Furthermore, `shouldComponentUpdate` skips updates for the whole component subtree. Make sure all the children components are also "pure".
|
||||
22
addons/react-addons-pure-render-mixin/index.js
vendored
Normal file
22
addons/react-addons-pure-render-mixin/index.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var shallowEqual = require('fbjs/lib/shallowEqual');
|
||||
|
||||
module.exports = {
|
||||
shouldComponentUpdate: function(nextProps, nextState) {
|
||||
return (
|
||||
!shallowEqual(this.props, nextProps) ||
|
||||
!shallowEqual(this.state, nextState)
|
||||
);
|
||||
}
|
||||
};
|
||||
36
addons/react-addons-pure-render-mixin/package.json
Normal file
36
addons/react-addons-pure-render-mixin/package.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "react-addons-pure-render-mixin",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.4",
|
||||
"object-assign": "^4.1.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js",
|
||||
"react-addons-pure-render-mixin.js",
|
||||
"react-addons-pure-render-mixin.min.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./react-addons-pure-render-mixin.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./react-addons-pure-render-mixin.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod && node ../postbuild.js",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.4.2",
|
||||
"react-dom": "^15.4.2",
|
||||
"webpack": "^2.6.1"
|
||||
}
|
||||
}
|
||||
@@ -12,35 +12,81 @@
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactDOM;
|
||||
var ReactComponentWithPureRenderMixin;
|
||||
var ReactTestUtils;
|
||||
|
||||
describe('ReactComponentWithPureRenderMixin', function() {
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.'
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message:
|
||||
'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
React = require('React');
|
||||
ReactComponentWithPureRenderMixin =
|
||||
require('ReactComponentWithPureRenderMixin');
|
||||
ReactTestUtils = require('ReactTestUtils');
|
||||
function renderIntoDocument(element) {
|
||||
var node = document.createElement('div');
|
||||
return ReactDOM.render(element, node);
|
||||
}
|
||||
|
||||
describe('PureRenderMixin', () => {
|
||||
beforeEach(() => {
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactComponentWithPureRenderMixin = require(process.env.TEST_ENTRY);
|
||||
});
|
||||
|
||||
it('provides a default shouldComponentUpdate implementation', function() {
|
||||
it('provides a default shouldComponentUpdate implementation', () => {
|
||||
var renderCalls = 0;
|
||||
class PlasticWrap extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
color: 'green',
|
||||
color: 'green'
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Apple
|
||||
color={this.state.color}
|
||||
ref="apple"
|
||||
/>
|
||||
);
|
||||
return React.createElement(Apple, {
|
||||
color: this.state.color,
|
||||
ref: 'apple'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,30 +96,30 @@ describe('ReactComponentWithPureRenderMixin', function() {
|
||||
getInitialState: function() {
|
||||
return {
|
||||
cut: false,
|
||||
slices: 1,
|
||||
slices: 1
|
||||
};
|
||||
},
|
||||
|
||||
cut: function() {
|
||||
this.setState({
|
||||
cut: true,
|
||||
slices: 10,
|
||||
slices: 10
|
||||
});
|
||||
},
|
||||
|
||||
eatSlice: function() {
|
||||
this.setState({
|
||||
slices: this.state.slices - 1,
|
||||
slices: this.state.slices - 1
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
renderCalls++;
|
||||
return <div />;
|
||||
},
|
||||
return React.createElement('div');
|
||||
}
|
||||
});
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(<PlasticWrap />);
|
||||
var instance = renderIntoDocument(React.createElement(PlasticWrap));
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
// Do not re-render based on props
|
||||
@@ -97,11 +143,11 @@ describe('ReactComponentWithPureRenderMixin', function() {
|
||||
expect(renderCalls).toBe(4);
|
||||
});
|
||||
|
||||
it('does not do a deep comparison', function() {
|
||||
it('does not do a deep comparison', () => {
|
||||
function getInitialState() {
|
||||
return {
|
||||
foo: [1, 2, 3],
|
||||
bar: {a: 4, b: 5, c: 6},
|
||||
bar: {a: 4, b: 5, c: 6}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,17 +163,17 @@ describe('ReactComponentWithPureRenderMixin', function() {
|
||||
|
||||
render: function() {
|
||||
renderCalls++;
|
||||
return <div />;
|
||||
},
|
||||
return React.createElement('div');
|
||||
}
|
||||
});
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(<Component />);
|
||||
var instance = renderIntoDocument(React.createElement(Component));
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
// Do not re-render if state is equal
|
||||
var settings = {
|
||||
foo: initialSettings.foo,
|
||||
bar: initialSettings.bar,
|
||||
bar: initialSettings.bar
|
||||
};
|
||||
instance.setState(settings);
|
||||
expect(renderCalls).toBe(1);
|
||||
@@ -141,5 +187,4 @@ describe('ReactComponentWithPureRenderMixin', function() {
|
||||
instance.setState(getInitialState());
|
||||
expect(renderCalls).toBe(3);
|
||||
});
|
||||
|
||||
});
|
||||
55
addons/react-addons-pure-render-mixin/webpack.config.js
Normal file
55
addons/react-addons-pure-render-mixin/webpack.config.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'PureRenderMixin',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__
|
||||
? 'react-addons-pure-render-mixin.js'
|
||||
: 'react-addons-pure-render-mixin.min.js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"'
|
||||
})
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
})
|
||||
]
|
||||
)
|
||||
};
|
||||
2814
addons/react-addons-pure-render-mixin/yarn.lock
Normal file
2814
addons/react-addons-pure-render-mixin/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
2
addons/react-addons-shallow-compare/.gitignore
vendored
Normal file
2
addons/react-addons-shallow-compare/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
react-addons-shallow-compare.js
|
||||
react-addons-shallow-compare.min.js
|
||||
31
addons/react-addons-shallow-compare/LICENSE
Normal file
31
addons/react-addons-shallow-compare/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-shallow-compare/PATENTS
Normal file
33
addons/react-addons-shallow-compare/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
53
addons/react-addons-shallow-compare/README.md
Normal file
53
addons/react-addons-shallow-compare/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# react-addons-shallow-compare
|
||||
|
||||
>**Note:**
|
||||
>This is a legacy React addon, and is no longer maintained.
|
||||
>
|
||||
>We don't encourage using it in new code, but it exists for backwards compatibility.
|
||||
>The recommended migration path is to use [`React.PureComponent`](https://facebook.github.io/react/docs/react-api.html#react.purecomponent) instead.
|
||||
|
||||
**Importing**
|
||||
|
||||
```javascript
|
||||
import shallowCompare from 'react-addons-shallow-compare'; // ES6
|
||||
var shallowCompare = require('react-addons-shallow-compare'); // ES5 with npm
|
||||
```
|
||||
|
||||
If you prefer a `<script>` tag, you can get it from `React.addons.shallowCompare` with:
|
||||
|
||||
```html
|
||||
<!-- development version -->
|
||||
<script src="https://unpkg.com/react-addons-shallow-compare/react-addons-shallow-compare.js"></script>
|
||||
|
||||
<!-- production version -->
|
||||
<script src="https://unpkg.com/react-addons-shallow-compare/react-addons-shallow-compare.min.js"></script>
|
||||
```
|
||||
|
||||
In this case, make sure to put the `<script>` tag after React.
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
Before [`React.PureComponent`](https://facebook.github.io/react/docs/react-api.html#react.purecomponent) was introduced, `shallowCompare` was commonly used to achieve the same functionality as [`PureRenderMixin`](https://www.npmjs.com/package/react-addons-pure-render-mixin) while using ES6 classes with React.
|
||||
|
||||
If your React component's render function is "pure" (in other words, it renders the same result given the same props and state), you can use this helper function for a performance boost in some cases.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
export class SampleComponent extends React.Component {
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
return shallowCompare(this, nextProps, nextState);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div className={this.props.className}>foo</div>;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`shallowCompare` performs a shallow equality check on the current `props` and `nextProps` objects as well as the current `state` and `nextState` objects.
|
||||
It does this by iterating on the keys of the objects being compared and returning true when the values of a key in each object are not strictly equal.
|
||||
|
||||
`shallowCompare` returns `true` if the shallow comparison for props or state fails and therefore the component should update.
|
||||
`shallowCompare` returns `false` if the shallow comparison for props and state both pass and therefore the component does not need to update.
|
||||
28
addons/react-addons-shallow-compare/index.js
vendored
Normal file
28
addons/react-addons-shallow-compare/index.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule shallowCompare
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var shallowEqual = require('fbjs/lib/shallowEqual');
|
||||
|
||||
/**
|
||||
* Does a shallow comparison for props and state.
|
||||
* See ReactComponentWithPureRenderMixin
|
||||
* See also https://facebook.github.io/react/docs/shallow-compare.html
|
||||
*/
|
||||
function shallowCompare(instance, nextProps, nextState) {
|
||||
return (
|
||||
!shallowEqual(instance.props, nextProps) ||
|
||||
!shallowEqual(instance.state, nextState)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = shallowCompare;
|
||||
36
addons/react-addons-shallow-compare/package.json
Normal file
36
addons/react-addons-shallow-compare/package.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "react-addons-shallow-compare",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.4",
|
||||
"object-assign": "^4.1.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js",
|
||||
"react-addons-shallow-compare.js",
|
||||
"react-addons-shallow-compare.min.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./react-addons-shallow-compare.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./react-addons-shallow-compare.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod && node ../postbuild.js",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.4.2",
|
||||
"react-dom": "^15.4.2",
|
||||
"webpack": "^2.6.1"
|
||||
}
|
||||
}
|
||||
271
addons/react-addons-shallow-compare/test.js
vendored
Normal file
271
addons/react-addons-shallow-compare/test.js
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactDOM;
|
||||
var shallowCompare;
|
||||
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.'
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message:
|
||||
'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
function renderIntoDocument(element) {
|
||||
var node = document.createElement('div');
|
||||
return ReactDOM.render(element, node);
|
||||
}
|
||||
|
||||
// Tests adapted from ReactComponentWithPureRendererMixin and ReactPureComponent tests
|
||||
describe('shallowCompare', () => {
|
||||
beforeEach(() => {
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
shallowCompare = require(process.env.TEST_ENTRY);
|
||||
});
|
||||
|
||||
it('should render', () => {
|
||||
var renders = 0;
|
||||
class Component extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {type: 'mushrooms'};
|
||||
}
|
||||
render() {
|
||||
renders++;
|
||||
return React.createElement('div', null, this.props.text[0]);
|
||||
}
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
return shallowCompare(this, nextProps, nextState);
|
||||
}
|
||||
}
|
||||
|
||||
var container = document.createElement('div');
|
||||
var text;
|
||||
var component;
|
||||
|
||||
text = ['porcini'];
|
||||
component = ReactDOM.render(
|
||||
React.createElement(Component, {text}),
|
||||
container
|
||||
);
|
||||
expect(container.textContent).toBe('porcini');
|
||||
expect(renders).toBe(1);
|
||||
|
||||
text = ['morel'];
|
||||
component = ReactDOM.render(
|
||||
React.createElement(Component, {text}),
|
||||
container
|
||||
);
|
||||
expect(container.textContent).toBe('morel');
|
||||
expect(renders).toBe(2);
|
||||
|
||||
text[0] = 'portobello';
|
||||
component = ReactDOM.render(
|
||||
React.createElement(Component, {text}),
|
||||
container
|
||||
);
|
||||
expect(container.textContent).toBe('morel');
|
||||
expect(renders).toBe(2);
|
||||
|
||||
// Setting state without changing it doesn't cause a rerender.
|
||||
component.setState({type: 'mushrooms'});
|
||||
expect(container.textContent).toBe('morel');
|
||||
expect(renders).toBe(2);
|
||||
|
||||
// But changing state does.
|
||||
component.setState({type: 'portobello mushrooms'});
|
||||
expect(container.textContent).toBe('portobello');
|
||||
expect(renders).toBe(3);
|
||||
});
|
||||
|
||||
it('can override shouldComponentUpdate', () => {
|
||||
var renders = 0;
|
||||
class Component extends React.PureComponent {
|
||||
render() {
|
||||
renders++;
|
||||
return React.createElement('div');
|
||||
}
|
||||
shouldComponentUpdate() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(React.createElement(Component), container);
|
||||
ReactDOM.render(React.createElement(Component), container);
|
||||
expect(renders).toBe(2);
|
||||
});
|
||||
|
||||
it('provides a default shouldComponentUpdate implementation', () => {
|
||||
var renderCalls = 0;
|
||||
class PlasticWrap extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
color: 'green'
|
||||
};
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
return shallowCompare(this, nextProps, nextState);
|
||||
}
|
||||
|
||||
render() {
|
||||
return React.createElement(Apple, {
|
||||
color: this.state.color,
|
||||
ref: 'apple'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var Apple = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
cut: false,
|
||||
slices: 1
|
||||
};
|
||||
},
|
||||
|
||||
cut: function() {
|
||||
this.setState({
|
||||
cut: true,
|
||||
slices: 10
|
||||
});
|
||||
},
|
||||
|
||||
eatSlice: function() {
|
||||
this.setState({
|
||||
slices: this.state.slices - 1
|
||||
});
|
||||
},
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
return shallowCompare(this, nextProps, nextState);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
renderCalls++;
|
||||
return React.createElement('div');
|
||||
}
|
||||
});
|
||||
|
||||
var instance = renderIntoDocument(React.createElement(PlasticWrap));
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
// Do not re-render based on props
|
||||
instance.setState({color: 'green'});
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
// Re-render based on props
|
||||
instance.setState({color: 'red'});
|
||||
expect(renderCalls).toBe(2);
|
||||
|
||||
// Re-render base on state
|
||||
instance.refs.apple.cut();
|
||||
expect(renderCalls).toBe(3);
|
||||
|
||||
// No re-render based on state
|
||||
instance.refs.apple.cut();
|
||||
expect(renderCalls).toBe(3);
|
||||
|
||||
// Re-render based on state again
|
||||
instance.refs.apple.eatSlice();
|
||||
expect(renderCalls).toBe(4);
|
||||
});
|
||||
|
||||
it('does not do a deep comparison', () => {
|
||||
function getInitialState() {
|
||||
return {
|
||||
foo: [1, 2, 3],
|
||||
bar: {a: 4, b: 5, c: 6}
|
||||
};
|
||||
}
|
||||
|
||||
var renderCalls = 0;
|
||||
var initialSettings = getInitialState();
|
||||
|
||||
var Component = React.createClass({
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
return shallowCompare(this, nextProps, nextState);
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return initialSettings;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
renderCalls++;
|
||||
return React.createElement('div');
|
||||
}
|
||||
});
|
||||
|
||||
var instance = renderIntoDocument(React.createElement(Component));
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
// Do not re-render if state is equal
|
||||
var settings = {
|
||||
foo: initialSettings.foo,
|
||||
bar: initialSettings.bar
|
||||
};
|
||||
instance.setState(settings);
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
// Re-render because one field changed
|
||||
initialSettings.foo = [1, 2, 3];
|
||||
instance.setState(initialSettings);
|
||||
expect(renderCalls).toBe(2);
|
||||
|
||||
// Re-render because the object changed
|
||||
instance.setState(getInitialState());
|
||||
expect(renderCalls).toBe(3);
|
||||
});
|
||||
});
|
||||
55
addons/react-addons-shallow-compare/webpack.config.js
Normal file
55
addons/react-addons-shallow-compare/webpack.config.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'shallowCompare',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__
|
||||
? 'react-addons-shallow-compare.js'
|
||||
: 'react-addons-shallow-compare.min.js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"'
|
||||
})
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
})
|
||||
]
|
||||
)
|
||||
};
|
||||
2814
addons/react-addons-shallow-compare/yarn.lock
Normal file
2814
addons/react-addons-shallow-compare/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
31
addons/react-addons-test-utils/LICENSE
Normal file
31
addons/react-addons-test-utils/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-test-utils/PATENTS
Normal file
33
addons/react-addons-test-utils/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
9
addons/react-addons-test-utils/README.md
Normal file
9
addons/react-addons-test-utils/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# react-addons-test-utils
|
||||
|
||||
This package provides the React TestUtils add-on.
|
||||
|
||||
See <https://facebook.github.io/react/docs/test-utils.html> for more information.
|
||||
|
||||
This package is deprecated as of version 15.5.0:
|
||||
* TestUtils have been moved to `react-dom/test-utils`
|
||||
* Shallow renderer has been moved to `react-test-renderer/shallow`
|
||||
75
addons/react-addons-test-utils/index.js
vendored
Normal file
75
addons/react-addons-test-utils/index.js
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var lowPriorityWarning = function lowPriorityWarning() {};
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var printWarning = function(format) {
|
||||
for (
|
||||
var _len = arguments.length,
|
||||
args = Array(_len > 1 ? _len - 1 : 0),
|
||||
_key = 1;
|
||||
_key < _len;
|
||||
_key++
|
||||
) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
var argIndex = 0;
|
||||
var message =
|
||||
'Warning: ' +
|
||||
format.replace(/%s/g, function() {
|
||||
return args[argIndex++];
|
||||
});
|
||||
if (typeof console !== 'undefined') {
|
||||
console.warn(message);
|
||||
}
|
||||
try {
|
||||
// --- Welcome to debugging React ---
|
||||
// This error was thrown as a convenience so that you can use this stack
|
||||
// to find the callsite that caused this warning to fire.
|
||||
throw new Error(message);
|
||||
} catch (x) {}
|
||||
};
|
||||
|
||||
lowPriorityWarning = function(condition, format) {
|
||||
if (format === undefined) {
|
||||
throw new Error(
|
||||
'`warning(condition, format, ...args)` requires a warning ' +
|
||||
'message argument'
|
||||
);
|
||||
}
|
||||
if (!condition) {
|
||||
for (
|
||||
var _len2 = arguments.length,
|
||||
args = Array(_len2 > 2 ? _len2 - 2 : 0),
|
||||
_key2 = 2;
|
||||
_key2 < _len2;
|
||||
_key2++
|
||||
) {
|
||||
args[_key2 - 2] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning.apply(undefined, [format].concat(args));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// This package has been deprecated in NPM as of version 15.5.0
|
||||
// But NPM deprecation warnings are easy to overlook
|
||||
// So a more explicit runtime warning seemed appropriate
|
||||
lowPriorityWarning(
|
||||
false,
|
||||
'ReactTestUtils has been moved to react-dom/test-utils. ' +
|
||||
'Update references to remove this warning.'
|
||||
);
|
||||
|
||||
module.exports = require('react-dom/lib/ReactTestUtils');
|
||||
29
addons/react-addons-test-utils/package.json
Normal file
29
addons/react-addons-test-utils/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "react-addons-test-utils",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"peerDependencies": {
|
||||
"react-dom": "^15.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"prepublish": "npm test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.4.2",
|
||||
"react-dom": "^15.4.2"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js"
|
||||
]
|
||||
}
|
||||
58
addons/react-addons-test-utils/test.js
vendored
Normal file
58
addons/react-addons-test-utils/test.js
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('ReactTestUtils', function() {
|
||||
let React;
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(console, 'warn');
|
||||
React = require('react');
|
||||
});
|
||||
|
||||
it('should warn on include', function() {
|
||||
require('./index');
|
||||
expect(console.warn).toHaveBeenCalledWith(
|
||||
'Warning: ReactTestUtils has been moved to react-dom/test-utils. ' +
|
||||
'Update references to remove this warning.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass a basic smoke test', function() {
|
||||
const ReactTestUtils = require('./index');
|
||||
const onClick = jest.fn();
|
||||
|
||||
class MyComponent extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this.state = {bar: 123};
|
||||
}
|
||||
render() {
|
||||
return <div onClick={onClick}>{this.props.baz}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MyComponent baz="abc" />
|
||||
);
|
||||
|
||||
expect(instance.state.bar).toBe(123);
|
||||
expect(instance.props.baz).toBe('abc');
|
||||
|
||||
const div = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'div');
|
||||
expect(div.textContent).toBe('abc');
|
||||
|
||||
expect(onClick).not.toHaveBeenCalled();
|
||||
ReactTestUtils.Simulate.click(div);
|
||||
expect(onClick).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
2057
addons/react-addons-test-utils/yarn.lock
Normal file
2057
addons/react-addons-test-utils/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
31
addons/react-addons-transition-group/LICENSE
Normal file
31
addons/react-addons-transition-group/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-transition-group/PATENTS
Normal file
33
addons/react-addons-transition-group/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
17
addons/react-addons-transition-group/README.md
Normal file
17
addons/react-addons-transition-group/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# react-addons-transition-group
|
||||
|
||||
The code in this package has moved. We recommend you to use `TransitionGroup` from [`react-transition-group`](https://github.com/reactjs/react-transition-group) instead.
|
||||
|
||||
In particular, its version `1.x` is a drop-in replacement for the last released version of `react-addons-transition-group`.
|
||||
|
||||
Run `npm install --save react-transition-group@1.x`, and replace the imports in your code:
|
||||
|
||||
```js
|
||||
// Old
|
||||
import TransitionGroup from 'react-addons-transition-group';
|
||||
|
||||
// New
|
||||
import TransitionGroup from 'react-transition-group/TransitionGroup';
|
||||
```
|
||||
|
||||
The documentation branch for `react-transition-group@1.x` [can be found here](https://github.com/reactjs/react-transition-group/tree/v1-stable#low-level-api-transitiongroup).
|
||||
12
addons/react-addons-transition-group/index.js
vendored
Normal file
12
addons/react-addons-transition-group/index.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = require('react-transition-group/TransitionGroup');
|
||||
26
addons/react-addons-transition-group/package.json
Normal file
26
addons/react-addons-transition-group/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "react-addons-transition-group",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"react-transition-group": "^1.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^15.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": ":"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js"
|
||||
]
|
||||
}
|
||||
114
addons/react-addons-transition-group/yarn.lock
Normal file
114
addons/react-addons-transition-group/yarn.lock
Normal file
@@ -0,0 +1,114 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
asap@~2.0.3:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f"
|
||||
|
||||
chain-function@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/chain-function/-/chain-function-1.0.0.tgz#0d4ab37e7e18ead0bdc47b920764118ce58733dc"
|
||||
|
||||
core-js@^1.0.0:
|
||||
version "1.2.7"
|
||||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
|
||||
|
||||
dom-helpers@^3.2.0:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.2.1.tgz#3203e07fed217bd1f424b019735582fc37b2825a"
|
||||
|
||||
encoding@^0.1.11:
|
||||
version "0.1.12"
|
||||
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
|
||||
dependencies:
|
||||
iconv-lite "~0.4.13"
|
||||
|
||||
fbjs@^0.8.9:
|
||||
version "0.8.12"
|
||||
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04"
|
||||
dependencies:
|
||||
core-js "^1.0.0"
|
||||
isomorphic-fetch "^2.1.1"
|
||||
loose-envify "^1.0.0"
|
||||
object-assign "^4.1.0"
|
||||
promise "^7.1.1"
|
||||
setimmediate "^1.0.5"
|
||||
ua-parser-js "^0.7.9"
|
||||
|
||||
iconv-lite@~0.4.13:
|
||||
version "0.4.17"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.17.tgz#4fdaa3b38acbc2c031b045d0edcdfe1ecab18c8d"
|
||||
|
||||
is-stream@^1.0.1:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
|
||||
|
||||
isomorphic-fetch@^2.1.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
|
||||
dependencies:
|
||||
node-fetch "^1.0.1"
|
||||
whatwg-fetch ">=0.10.0"
|
||||
|
||||
js-tokens@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"
|
||||
|
||||
loose-envify@^1.0.0, loose-envify@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
|
||||
dependencies:
|
||||
js-tokens "^3.0.0"
|
||||
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5"
|
||||
dependencies:
|
||||
encoding "^0.1.11"
|
||||
is-stream "^1.0.1"
|
||||
|
||||
object-assign@^4.1.0:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
|
||||
promise@^7.1.1:
|
||||
version "7.1.1"
|
||||
resolved "https://registry.yarnpkg.com/promise/-/promise-7.1.1.tgz#489654c692616b8aa55b0724fa809bb7db49c5bf"
|
||||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
prop-types@^15.5.6:
|
||||
version "15.5.10"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
|
||||
dependencies:
|
||||
fbjs "^0.8.9"
|
||||
loose-envify "^1.3.1"
|
||||
|
||||
react-transition-group@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-1.2.0.tgz#b51fc921b0c3835a7ef7c571c79fc82c73e9204f"
|
||||
dependencies:
|
||||
chain-function "^1.0.0"
|
||||
dom-helpers "^3.2.0"
|
||||
loose-envify "^1.3.1"
|
||||
prop-types "^15.5.6"
|
||||
warning "^3.0.0"
|
||||
|
||||
setimmediate@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
|
||||
|
||||
ua-parser-js@^0.7.9:
|
||||
version "0.7.12"
|
||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"
|
||||
|
||||
warning@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"
|
||||
dependencies:
|
||||
loose-envify "^1.0.0"
|
||||
|
||||
whatwg-fetch@>=0.10.0:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
|
||||
2
addons/react-addons-update/.gitignore
vendored
Normal file
2
addons/react-addons-update/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
react-addons-update.js
|
||||
react-addons-update.min.js
|
||||
31
addons/react-addons-update/LICENSE.txt
Normal file
31
addons/react-addons-update/LICENSE.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-addons-update/PATENTS
Normal file
33
addons/react-addons-update/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
125
addons/react-addons-update/README.md
Normal file
125
addons/react-addons-update/README.md
Normal file
@@ -0,0 +1,125 @@
|
||||
# react-addons-update
|
||||
|
||||
>**Note:**
|
||||
>This is a legacy React addon, and is no longer maintained.
|
||||
>
|
||||
>We don't encourage using it in new code, but it exists for backwards compatibility.
|
||||
>The recommended migration path is to use [`immutability-helper`](https://github.com/kolodny/immutability-helper). Its version `1.0.0` is a drop-in replacement.
|
||||
|
||||
**Importing**
|
||||
|
||||
```javascript
|
||||
import update from 'react-addons-update'; // ES6
|
||||
var update = require('react-addons-update'); // ES5 with npm
|
||||
```
|
||||
|
||||
If you prefer a `<script>` tag, you can get it from `React.addons.update` with:
|
||||
|
||||
```html
|
||||
<!-- development version -->
|
||||
<script src="https://unpkg.com/react-addons-update/react-addons-update.js"></script>
|
||||
|
||||
<!-- production version -->
|
||||
<script src="https://unpkg.com/react-addons-update/react-addons-update.min.js"></script>
|
||||
```
|
||||
|
||||
In this case, make sure to put the `<script>` tag after React.
|
||||
|
||||
## Overview
|
||||
|
||||
React lets you use whatever style of data management you want, including mutation. However, if you can use immutable data in performance-critical parts of your application it's easy to implement a fast [`shouldComponentUpdate()`](https://facebook.github.io/react/docs/react-component.html#shouldcomponentupdate) method to significantly speed up your app.
|
||||
|
||||
Dealing with immutable data in JavaScript is more difficult than in languages designed for it, like [Clojure](http://clojure.org/). However, we've provided a simple immutability helper, `update()`, that makes dealing with this type of data much easier, *without* fundamentally changing how your data is represented. You can also take a look at Facebook's [Immutable-js](https://facebook.github.io/immutable-js/docs/) and the [Optimizing Performance](https://facebook.github.io/react/docs/optimizing-performance.html) section for more detail on Immutable-js.
|
||||
|
||||
### The Main Idea
|
||||
|
||||
If you mutate data like this:
|
||||
|
||||
```js
|
||||
myData.x.y.z = 7;
|
||||
// or...
|
||||
myData.a.b.push(9);
|
||||
```
|
||||
|
||||
You have no way of determining which data has changed since the previous copy has been overwritten. Instead, you need to create a new copy of `myData` and change only the parts of it that need to be changed. Then you can compare the old copy of `myData` with the new one in `shouldComponentUpdate()` using triple-equals:
|
||||
|
||||
```js
|
||||
const newData = deepCopy(myData);
|
||||
newData.x.y.z = 7;
|
||||
newData.a.b.push(9);
|
||||
```
|
||||
|
||||
Unfortunately, deep copies are expensive, and sometimes impossible. You can alleviate this by only copying objects that need to be changed and by reusing the objects that haven't changed. Unfortunately, in today's JavaScript this can be cumbersome:
|
||||
|
||||
```js
|
||||
const newData = extend(myData, {
|
||||
x: extend(myData.x, {
|
||||
y: extend(myData.x.y, {z: 7}),
|
||||
}),
|
||||
a: extend(myData.a, {b: myData.a.b.concat(9)})
|
||||
});
|
||||
```
|
||||
|
||||
While this is fairly performant (since it only makes a shallow copy of `log n` objects and reuses the rest), it's a big pain to write. Look at all the repetition! This is not only annoying, but also provides a large surface area for bugs.
|
||||
|
||||
## `update()`
|
||||
|
||||
`update()` provides simple syntactic sugar around this pattern to make writing this code easier. This code becomes:
|
||||
|
||||
```js
|
||||
import update from 'react-addons-update';
|
||||
|
||||
const newData = update(myData, {
|
||||
x: {y: {z: {$set: 7}}},
|
||||
a: {b: {$push: [9]}}
|
||||
});
|
||||
```
|
||||
|
||||
While the syntax takes a little getting used to (though it's inspired by [MongoDB's query language](http://docs.mongodb.org/manual/core/crud-introduction/#query)) there's no redundancy, it's statically analyzable and it's not much more typing than the mutative version.
|
||||
|
||||
The `$`-prefixed keys are called *commands*. The data structure they are "mutating" is called the *target*.
|
||||
|
||||
## Available Commands
|
||||
|
||||
* `{$push: array}` `push()` all the items in `array` on the target.
|
||||
* `{$unshift: array}` `unshift()` all the items in `array` on the target.
|
||||
* `{$splice: array of arrays}` for each item in `arrays` call `splice()` on the target with the parameters provided by the item.
|
||||
* `{$set: any}` replace the target entirely.
|
||||
* `{$merge: object}` merge the keys of `object` with the target.
|
||||
* `{$apply: function}` passes in the current value to the function and updates it with the new returned value.
|
||||
|
||||
## Examples
|
||||
|
||||
### Simple push
|
||||
|
||||
```js
|
||||
const initialArray = [1, 2, 3];
|
||||
const newArray = update(initialArray, {$push: [4]}); // => [1, 2, 3, 4]
|
||||
```
|
||||
`initialArray` is still `[1, 2, 3]`.
|
||||
|
||||
### Nested collections
|
||||
|
||||
```js
|
||||
const collection = [1, 2, {a: [12, 17, 15]}];
|
||||
const newCollection = update(collection, {2: {a: {$splice: [[1, 1, 13, 14]]}}});
|
||||
// => [1, 2, {a: [12, 13, 14, 15]}]
|
||||
```
|
||||
This accesses `collection`'s index `2`, key `a`, and does a splice of one item starting from index `1` (to remove `17`) while inserting `13` and `14`.
|
||||
|
||||
### Updating a value based on its current one
|
||||
|
||||
```js
|
||||
const obj = {a: 5, b: 3};
|
||||
const newObj = update(obj, {b: {$apply: function(x) {return x * 2;}}});
|
||||
// => {a: 5, b: 6}
|
||||
// This is equivalent, but gets verbose for deeply nested collections:
|
||||
const newObj2 = update(obj, {b: {$set: obj.b * 2}});
|
||||
```
|
||||
|
||||
### (Shallow) Merge
|
||||
|
||||
```js
|
||||
const obj = {a: 5, b: 3};
|
||||
const newObj = update(obj, {$merge: {b: 6, c: 7}}); // => {a: 5, b: 6, c: 7}
|
||||
```
|
||||
166
addons/react-addons-update/index.js
vendored
Normal file
166
addons/react-addons-update/index.js
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _assign = require('object-assign');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var hasOwnProperty = {}.hasOwnProperty;
|
||||
|
||||
function shallowCopy(x) {
|
||||
if (Array.isArray(x)) {
|
||||
return x.concat();
|
||||
} else if (x && typeof x === 'object') {
|
||||
return _assign(new x.constructor(), x);
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
var COMMAND_PUSH = '$push';
|
||||
var COMMAND_UNSHIFT = '$unshift';
|
||||
var COMMAND_SPLICE = '$splice';
|
||||
var COMMAND_SET = '$set';
|
||||
var COMMAND_MERGE = '$merge';
|
||||
var COMMAND_APPLY = '$apply';
|
||||
|
||||
var ALL_COMMANDS_LIST = [
|
||||
COMMAND_PUSH,
|
||||
COMMAND_UNSHIFT,
|
||||
COMMAND_SPLICE,
|
||||
COMMAND_SET,
|
||||
COMMAND_MERGE,
|
||||
COMMAND_APPLY
|
||||
];
|
||||
|
||||
var ALL_COMMANDS_SET = {};
|
||||
|
||||
ALL_COMMANDS_LIST.forEach(function(command) {
|
||||
ALL_COMMANDS_SET[command] = true;
|
||||
});
|
||||
|
||||
function invariantArrayCase(value, spec, command) {
|
||||
invariant(
|
||||
Array.isArray(value),
|
||||
'update(): expected target of %s to be an array; got %s.',
|
||||
command,
|
||||
value
|
||||
);
|
||||
var specValue = spec[command];
|
||||
invariant(
|
||||
Array.isArray(specValue),
|
||||
'update(): expected spec of %s to be an array; got %s. ' +
|
||||
'Did you forget to wrap your parameter in an array?',
|
||||
command,
|
||||
specValue
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a updated shallow copy of an object without mutating the original.
|
||||
* See https://facebook.github.io/react/docs/update.html for details.
|
||||
*/
|
||||
function update(value, spec) {
|
||||
invariant(
|
||||
typeof spec === 'object',
|
||||
'update(): You provided a key path to update() that did not contain one ' +
|
||||
'of %s. Did you forget to include {%s: ...}?',
|
||||
ALL_COMMANDS_LIST.join(', '),
|
||||
COMMAND_SET
|
||||
);
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_SET)) {
|
||||
invariant(
|
||||
Object.keys(spec).length === 1,
|
||||
'Cannot have more than one key in an object with %s',
|
||||
COMMAND_SET
|
||||
);
|
||||
|
||||
return spec[COMMAND_SET];
|
||||
}
|
||||
|
||||
var nextValue = shallowCopy(value);
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
|
||||
var mergeObj = spec[COMMAND_MERGE];
|
||||
invariant(
|
||||
mergeObj && typeof mergeObj === 'object',
|
||||
"update(): %s expects a spec of type 'object'; got %s",
|
||||
COMMAND_MERGE,
|
||||
mergeObj
|
||||
);
|
||||
invariant(
|
||||
nextValue && typeof nextValue === 'object',
|
||||
"update(): %s expects a target of type 'object'; got %s",
|
||||
COMMAND_MERGE,
|
||||
nextValue
|
||||
);
|
||||
_assign(nextValue, spec[COMMAND_MERGE]);
|
||||
}
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_PUSH)) {
|
||||
invariantArrayCase(value, spec, COMMAND_PUSH);
|
||||
spec[COMMAND_PUSH].forEach(function(item) {
|
||||
nextValue.push(item);
|
||||
});
|
||||
}
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_UNSHIFT)) {
|
||||
invariantArrayCase(value, spec, COMMAND_UNSHIFT);
|
||||
spec[COMMAND_UNSHIFT].forEach(function(item) {
|
||||
nextValue.unshift(item);
|
||||
});
|
||||
}
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
|
||||
invariant(
|
||||
Array.isArray(value),
|
||||
'Expected %s target to be an array; got %s',
|
||||
COMMAND_SPLICE,
|
||||
value
|
||||
);
|
||||
invariant(
|
||||
Array.isArray(spec[COMMAND_SPLICE]),
|
||||
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
||||
'Did you forget to wrap your parameters in an array?',
|
||||
COMMAND_SPLICE,
|
||||
spec[COMMAND_SPLICE]
|
||||
);
|
||||
spec[COMMAND_SPLICE].forEach(function(args) {
|
||||
invariant(
|
||||
Array.isArray(args),
|
||||
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
||||
'Did you forget to wrap your parameters in an array?',
|
||||
COMMAND_SPLICE,
|
||||
spec[COMMAND_SPLICE]
|
||||
);
|
||||
nextValue.splice.apply(nextValue, args);
|
||||
});
|
||||
}
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
|
||||
invariant(
|
||||
typeof spec[COMMAND_APPLY] === 'function',
|
||||
'update(): expected spec of %s to be a function; got %s.',
|
||||
COMMAND_APPLY,
|
||||
spec[COMMAND_APPLY]
|
||||
);
|
||||
nextValue = spec[COMMAND_APPLY](nextValue);
|
||||
}
|
||||
|
||||
for (var k in spec) {
|
||||
if (!(ALL_COMMANDS_SET.hasOwnProperty(k) && ALL_COMMANDS_SET[k])) {
|
||||
nextValue[k] = update(value[k], spec[k]);
|
||||
}
|
||||
}
|
||||
|
||||
return nextValue;
|
||||
}
|
||||
|
||||
module.exports = update;
|
||||
34
addons/react-addons-update/package.json
Normal file
34
addons/react-addons-update/package.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "react-addons-update",
|
||||
"version": "15.6.0",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.9",
|
||||
"object-assign": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"webpack": "^2.6.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./react-addons-update.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./react-addons-update.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod && node ../postbuild.js",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"README.md",
|
||||
"index.js",
|
||||
"react-addons-update.js",
|
||||
"react-addons-update.min.js"
|
||||
]
|
||||
}
|
||||
112
addons/react-addons-update/test.js
vendored
Normal file
112
addons/react-addons-update/test.js
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.'
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message:
|
||||
'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
const update = require(process.env.TEST_ENTRY);
|
||||
|
||||
describe('update', () => {
|
||||
// https://facebook.github.io/react/docs/update.html#simple-push
|
||||
it('should support simple push', () => {
|
||||
const array = [1, 2, 3];
|
||||
|
||||
const newArray = update(array, {$push: [4]});
|
||||
expect(array).toEqual([1, 2, 3]);
|
||||
|
||||
expect(newArray).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
// https://facebook.github.io/react/docs/update.html#nested-collections
|
||||
it('should support nested collections', () => {
|
||||
const collection = [1, 2, {a: [12, 17, 15]}];
|
||||
|
||||
const newCollection = update(collection, {
|
||||
2: {a: {$splice: [[1, 1, 13, 14]]}}
|
||||
});
|
||||
expect(collection).toEqual([1, 2, {a: [12, 17, 15]}]);
|
||||
|
||||
expect(newCollection).toEqual([1, 2, {a: [12, 13, 14, 15]}]);
|
||||
});
|
||||
|
||||
// https://facebook.github.io/react/docs/update.html#updating-a-value-based-on-its-current-one
|
||||
it('should support updating a value based on its current one', () => {
|
||||
const obj = {a: 5, b: 3};
|
||||
|
||||
const newObj = update(obj, {
|
||||
b: {
|
||||
$apply: function(x) {
|
||||
return x * 2;
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(newObj).toEqual({a: 5, b: 6});
|
||||
|
||||
const newObj2 = update(obj, {b: {$set: obj.b * 2}});
|
||||
expect(newObj2).toEqual({a: 5, b: 6});
|
||||
|
||||
expect(obj).toEqual({a: 5, b: 3});
|
||||
});
|
||||
|
||||
// https://facebook.github.io/react/docs/update.html#shallow-merge
|
||||
it('should support shallow merge', () => {
|
||||
const obj = {a: 5, b: 3};
|
||||
|
||||
const newObj = update(obj, {$merge: {b: 6, c: 7}});
|
||||
expect(newObj).toEqual({a: 5, b: 6, c: 7});
|
||||
|
||||
expect(obj).toEqual({a: 5, b: 3});
|
||||
});
|
||||
});
|
||||
53
addons/react-addons-update/webpack.config.js
Normal file
53
addons/react-addons-update/webpack.config.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'update',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__ ? 'react-addons-update.js' : 'react-addons-update.min.js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"'
|
||||
})
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
})
|
||||
]
|
||||
)
|
||||
};
|
||||
2811
addons/react-addons-update/yarn.lock
Normal file
2811
addons/react-addons-update/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
2
addons/react-linked-input/.gitignore
vendored
Normal file
2
addons/react-linked-input/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
react-linked-input.js
|
||||
react-linked-input.min.js
|
||||
31
addons/react-linked-input/LICENSE.txt
Normal file
31
addons/react-linked-input/LICENSE.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
addons/react-linked-input/PATENTS
Normal file
33
addons/react-linked-input/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
11
addons/react-linked-input/README.md
Normal file
11
addons/react-linked-input/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# react-linked-input
|
||||
|
||||
>**Note:**
|
||||
>This is a legacy React addon, and is no longer maintained.
|
||||
>
|
||||
>We don't encourage using it in new code, but it exists for backwards compatibility.
|
||||
>The recommended migration path is to set `value` and `onChange` props directly instead of `valueLink` or `checkedLink`.
|
||||
|
||||
This component supports the legacy `valueLink` API for `<input>` components. The built-in support for it is being removed from React. This component may be used as a migration plan (so your code doesn't break in React 16) or may be used if you just like the `valueLink` data binding semantics. However, this component is not maintained, so use at your own risk.
|
||||
|
||||
For details on how to use it, refer to the [`LinkedStateMixin`](https://www.npmjs.com/package/react-addons-linked-state-mixin) documentation, since they usually appear together.
|
||||
167
addons/react-linked-input/index.js
vendored
Normal file
167
addons/react-linked-input/index.js
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
if (typeof React === 'undefined') {
|
||||
throw Error(
|
||||
'react-linked-input could not find the React object. If you are using script tags, ' +
|
||||
'make sure that React is being loaded before react-linked-input.'
|
||||
);
|
||||
}
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
function _assertSingleLink(inputProps) {
|
||||
invariant(
|
||||
inputProps.checkedLink == null || inputProps.valueLink == null,
|
||||
'Cannot provide a checkedLink and a valueLink. If you want to use ' +
|
||||
"checkedLink, you probably don't want to use valueLink and vice versa."
|
||||
);
|
||||
}
|
||||
function _assertValueLink(inputProps) {
|
||||
_assertSingleLink(inputProps);
|
||||
invariant(
|
||||
inputProps.value == null && inputProps.onChange == null,
|
||||
'Cannot provide a valueLink and a value or onChange event. If you want ' +
|
||||
"to use value or onChange, you probably don't want to use valueLink."
|
||||
);
|
||||
}
|
||||
|
||||
function _assertCheckedLink(inputProps) {
|
||||
_assertSingleLink(inputProps);
|
||||
invariant(
|
||||
inputProps.checked == null && inputProps.onChange == null,
|
||||
'Cannot provide a checkedLink and a checked property or onChange event. ' +
|
||||
"If you want to use checked or onChange, you probably don't want to " +
|
||||
'use checkedLink'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a linked `value` attribute for controlled forms. You should not use
|
||||
* this outside of the ReactDOM controlled form components.
|
||||
*/
|
||||
var LinkedValueUtils = {
|
||||
/**
|
||||
* @param {object} inputProps Props for form component
|
||||
* @return {*} current value of the input either from value prop or link.
|
||||
*/
|
||||
getValue: function(inputProps) {
|
||||
if (inputProps.valueLink) {
|
||||
_assertValueLink(inputProps);
|
||||
return inputProps.valueLink.value;
|
||||
}
|
||||
return inputProps.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {object} inputProps Props for form component
|
||||
* @return {*} current checked status of the input either from checked prop
|
||||
* or link.
|
||||
*/
|
||||
getChecked: function(inputProps) {
|
||||
if (inputProps.checkedLink) {
|
||||
_assertCheckedLink(inputProps);
|
||||
return inputProps.checkedLink.value;
|
||||
}
|
||||
return inputProps.checked;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {object} inputProps Props for form component
|
||||
* @param {SyntheticEvent} event change event to handle
|
||||
*/
|
||||
executeOnChange: function(inputProps, event) {
|
||||
if (inputProps.valueLink) {
|
||||
_assertValueLink(inputProps);
|
||||
return inputProps.valueLink.requestChange(event.target.value);
|
||||
} else if (inputProps.checkedLink) {
|
||||
_assertCheckedLink(inputProps);
|
||||
return inputProps.checkedLink.requestChange(event.target.checked);
|
||||
} else if (inputProps.onChange) {
|
||||
return inputProps.onChange.call(undefined, event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError('Cannot call a class as a function');
|
||||
}
|
||||
}
|
||||
|
||||
function _possibleConstructorReturn(self, call) {
|
||||
if (!self) {
|
||||
throw new ReferenceError(
|
||||
"this hasn't been initialised - super() hasn't been called"
|
||||
);
|
||||
}
|
||||
return call && (typeof call === 'object' || typeof call === 'function')
|
||||
? call
|
||||
: self;
|
||||
}
|
||||
|
||||
function _inherits(subClass, superClass) {
|
||||
if (typeof superClass !== 'function' && superClass !== null) {
|
||||
throw new TypeError(
|
||||
'Super expression must either be null or a function, not ' +
|
||||
typeof superClass
|
||||
);
|
||||
}
|
||||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||
constructor: {
|
||||
value: subClass,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (superClass) {
|
||||
if (Object.setPrototypeOf) {
|
||||
Object.setPrototypeOf(subClass, superClass);
|
||||
} else {
|
||||
// eslint-disable-next-line no-proto
|
||||
subClass.__proto__ = superClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var LI = (function(_React$Component) {
|
||||
_inherits(LinkedInput, _React$Component);
|
||||
|
||||
function LinkedInput() {
|
||||
_classCallCheck(this, LinkedInput);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, _React$Component.call(this));
|
||||
|
||||
_this.handleChange = _this.handleChange.bind(_this);
|
||||
return _this;
|
||||
}
|
||||
|
||||
LinkedInput.prototype.handleChange = function handleChange(e) {
|
||||
LinkedValueUtils.executeOnChange(this.props, e);
|
||||
};
|
||||
|
||||
LinkedInput.prototype.render = function render() {
|
||||
var newProps = Object.assign({}, this.props);
|
||||
newProps.value = LinkedValueUtils.getValue(this.props);
|
||||
newProps.checked = LinkedValueUtils.getChecked(this.props);
|
||||
newProps.onChange = this.handleChange;
|
||||
delete newProps.valueLink;
|
||||
delete newProps.checkedLink;
|
||||
return React.createElement('input', newProps);
|
||||
};
|
||||
|
||||
return LinkedInput;
|
||||
})(React.Component);
|
||||
|
||||
module.exports = LI;
|
||||
43
addons/react-linked-input/package.json
Normal file
43
addons/react-linked-input/package.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "react-linked-input",
|
||||
"version": "15.6.0",
|
||||
"description": "LinkedInput supports the ReactLink semantics",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./react-linked-input.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./react-linked-input.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/facebook/react.git"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
"factory.js",
|
||||
"index.js",
|
||||
"react-linked-input.js",
|
||||
"react-linked-input.min.js"
|
||||
],
|
||||
"keywords": [
|
||||
"react",
|
||||
"linkedinput",
|
||||
"input",
|
||||
"linked",
|
||||
"reactlink"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"devDependencies": {
|
||||
"babel-preset-es2015": "^6.24.0",
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.4.2",
|
||||
"react-dom": "^15.4.2",
|
||||
"webpack": "^2.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.9"
|
||||
}
|
||||
}
|
||||
109
addons/react-linked-input/test.js
vendored
Normal file
109
addons/react-linked-input/test.js
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.'
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message:
|
||||
'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Tests adapted from ReactComponentWithPureRendererMixin and ReactPureComponent tests
|
||||
describe('LinkedInput', function() {
|
||||
let LinkedInput;
|
||||
let React;
|
||||
let ReactDOM;
|
||||
|
||||
beforeEach(function() {
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
LinkedInput = require(process.env.TEST_ENTRY);
|
||||
});
|
||||
|
||||
it('should basically work', function() {
|
||||
spyOn(console, 'error'); // Unknown prop `requestChange` on <input> tag
|
||||
|
||||
const container = document.createElement('div');
|
||||
const component = ReactDOM.render(
|
||||
React.createElement(LinkedInput, {
|
||||
value: 'foo',
|
||||
onChange: noop
|
||||
}),
|
||||
container
|
||||
);
|
||||
const input = ReactDOM.findDOMNode(component);
|
||||
expect(input.value).toBe('foo');
|
||||
ReactDOM.render(
|
||||
React.createElement(LinkedInput, {
|
||||
valueLink: {value: 'boo'},
|
||||
requestChange: noop
|
||||
}),
|
||||
container
|
||||
);
|
||||
expect(input.value).toBe('boo');
|
||||
});
|
||||
|
||||
it('should throw', function() {
|
||||
const container = document.createElement('div');
|
||||
const element = React.createElement(LinkedInput, {
|
||||
value: 'foo',
|
||||
valueLink: {
|
||||
value: 'boo',
|
||||
requestChange: noop
|
||||
}
|
||||
});
|
||||
expect(function() {
|
||||
ReactDOM.render(element, container);
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
61
addons/react-linked-input/webpack.config.js
Normal file
61
addons/react-linked-input/webpack.config.js
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'LinkedInput',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__ ? 'react-linked-input.js' : 'react-linked-input.min.js'
|
||||
},
|
||||
externals: {
|
||||
react: {
|
||||
root: 'React',
|
||||
commonjs2: 'react',
|
||||
commonjs: 'react',
|
||||
amd: 'react'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"'
|
||||
})
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
})
|
||||
]
|
||||
)
|
||||
};
|
||||
3145
addons/react-linked-input/yarn.lock
Normal file
3145
addons/react-linked-input/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
23
addons/test.js
Normal file
23
addons/test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var spawnSync = require('child_process').spawnSync;
|
||||
|
||||
function runNpmCommand(dir, args) {
|
||||
const result = spawnSync('npm', args, {
|
||||
cwd: path.join(__dirname, dir),
|
||||
stdio: 'inherit'
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
process.exit('npm test exited with non-zero code.');
|
||||
}
|
||||
}
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
.filter(file => {
|
||||
return fs.statSync(path.join(__dirname, file)).isDirectory();
|
||||
})
|
||||
.forEach(dir => {
|
||||
runNpmCommand(dir, ['install']);
|
||||
runNpmCommand(dir, ['run', 'prepublish']);
|
||||
});
|
||||
46
circle.yml
Normal file
46
circle.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
machine:
|
||||
timezone: America/Los_Angeles
|
||||
node:
|
||||
version: 6
|
||||
ruby:
|
||||
version: 2.2.3
|
||||
environment:
|
||||
TRAVIS_REPO_SLUG: facebook/react
|
||||
YARN_VERSION: 0.17.8
|
||||
PATH: "${PATH}:${HOME}/.yarn/bin"
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
# This is equivalent to $TRAVIS_COMMIT_RANGE
|
||||
# Need to figure out how to bail early if this is a "docs only" build
|
||||
- echo $CIRCLE_COMPARE_URL | cut -d/ -f7
|
||||
# install yarn if it's not already installed
|
||||
- |
|
||||
if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
|
||||
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
|
||||
fi
|
||||
override:
|
||||
- bundle install --gemfile=docs/Gemfile --deployment --path=vendor/bundle --jobs=3 --retry=3
|
||||
- yarn install
|
||||
- scripts/circleci/set_up_github_keys.sh
|
||||
post:
|
||||
# - npm ls --depth=0
|
||||
cache_directories:
|
||||
- docs/vendor/bundle
|
||||
- .grunt # Show size comparisons between builds
|
||||
- ~/react-gh-pages # docs checkout
|
||||
- ~/.yarn
|
||||
- ~/.yarn-cache
|
||||
|
||||
test:
|
||||
override:
|
||||
- ./scripts/circleci/test_entry_point.sh:
|
||||
parallel: true
|
||||
|
||||
deployment:
|
||||
staging:
|
||||
branch: /.*/
|
||||
commands:
|
||||
- ./scripts/circleci/upload_build.sh
|
||||
- ./scripts/circleci/build_gh_pages.sh
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: single
|
||||
title: Page Not Found
|
||||
permalink: 404.html
|
||||
---
|
||||
|
||||
We couldn't find what you were looking for.
|
||||
|
||||
16
docs/Gemfile
16
docs/Gemfile
@@ -3,11 +3,12 @@ source 'https://rubygems.org'
|
||||
gem 'rake'
|
||||
|
||||
# jekyll, which builds it all
|
||||
# 2.0 includes sass processing
|
||||
gem 'jekyll', '~>2.0'
|
||||
# 3.0 includes sass processing
|
||||
gem 'jekyll', '~>3.1'
|
||||
|
||||
# Auto redirect pages
|
||||
# Jekyll extensions
|
||||
gem 'jekyll-redirect-from'
|
||||
gem 'jekyll-paginate'
|
||||
|
||||
# JSON
|
||||
gem 'json'
|
||||
@@ -17,3 +18,12 @@ gem 'rb-fsevent'
|
||||
|
||||
# For markdown header cleanup
|
||||
gem 'sanitize', '~>2.0'
|
||||
|
||||
# Markdown
|
||||
gem 'redcarpet'
|
||||
|
||||
# Syntax highlighting
|
||||
gem 'pygments.rb'
|
||||
|
||||
# Avoid having to poll for changes on Windows
|
||||
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user