Skip to content

Commit d779223

Browse files
author
古映杰
committed
update README.md
1 parent 17c74bf commit d779223

11 files changed

Lines changed: 410 additions & 398 deletions

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ react-lite is an implementation of React that optimizes for small script size.
1717
| React | 0.14.3 | 136.0kb |
1818
| Web Components Polyfill| 0.7.19 | 118.0kb |
1919
| Riot | 2.3.11 | 20kb |
20-
| React-lite | 0.0.18 | 17.5kb |
20+
| React-lite | 0.0.23 | 20kb |
2121

2222
It supports the core APIs of React, such as Virtual DOM, intended as a drop-in
23-
replacement for React, when you don't need server-side rendering in browser(no React.renderToString/React.renderToStaticMarkup).
23+
replacement for React, when you don't need server-side rendering in browser(no `React.renderToString` & `React.renderToStaticMarkup`).
2424

2525
If you are using webpack, it's so easy to use react-lite, just [config alias](http://webpack.github.io/docs/configuration.html#resolve-alias) in webpack.config.js:
2626

@@ -47,7 +47,7 @@ npm install --save react-lite
4747

4848
## Browser compatibility
4949

50-
supports IE9+ ES5 enviroment
50+
supports IE9+ / ES5 enviroment
5151

5252

5353
## Documentation
@@ -58,23 +58,25 @@ learn react-lite from [React official documentation](http://facebook.github.io/r
5858

5959
just the same as what react does, see some demos below(I just add the alias to webpack.config.js, no need to do anything else):
6060

61-
- react-lite works with react-bootstrap: [doc demo](http://react-lite-with-bootstrap.herokuapp.com/)
62-
- react-lite works with react-router: [examples](http://react-lite-with-react-router.coding.io/)
63-
- react-lite works with redux:
61+
- works with react-bootstrap: [doc demo](http://react-lite-with-bootstrap.herokuapp.com/)
62+
- works with react-router: [examples](http://react-lite-with-react-router.coding.io/)
63+
- works with redux:
6464
* [async](http://lucifier129.github.io/redux-with-react-lite/async/index.html)
6565
* [counter](http://lucifier129.github.io/redux-with-react-lite/counter/index.html)
6666
* [shopping-cart](http://lucifier129.github.io/redux-with-react-lite/shopping-cart/index.html)
6767
* [todomvc](http://lucifier129.github.io/redux-with-react-lite/todomvc/index.html)
6868
* [todos-with-undo](http://lucifier129.github.io/redux-with-react-lite/todos-with-undo/index.html)
69-
- react-lite works with react-motion: [demos](http://lucifier129.github.io/react-motion-with-react-lite/index.html)
69+
- works with react-motion: [demos](http://lucifier129.github.io/react-motion-with-react-lite/index.html)
70+
- works with react-d3-components: [demos](http://lucifier129.github.io/react-d3-components-demos/)
71+
- works with react-d3: [demos](http://lucifier129.github.io/react-d3-demos/)
7072
- js-repaint-perf(which is faster?):
7173
* [react](http://lucifier129.github.io/react-lite-repaint-perf/react/index.html)
7274
* [react-lite](http://lucifier129.github.io/react-lite-repaint-perf/react/lite.html)
7375

7476
## React-lite vs React
7577

7678
via react-lite:
77-
- virtual-dom can not render to string(no React.renderToString and React.renderToStaticMarkup)
79+
- In browser, virtual-dom can not render to string(no `React.renderToString` and `React.renderToStaticMarkup`)
7880
- event system is base on delegation pattern(since v0.0.19)
7981
- all of React.PropTypes method is noop(empty function)
8082
- Do not support React-addons(for example ReactCSSTransitionGroup)

dist/react-lite.common.js

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* react-lite.js v0.0.22
2+
* react-lite.js v0.0.23
33
* (c) 2016 Jade Gu
44
* Released under the MIT License.
55
*/
@@ -11,6 +11,21 @@ var xml = 'http://www.w3.org/XML/1998/namespace';
1111

1212
var SVGNamespaceURI = 'http://www.w3.org/2000/svg';
1313

14+
var VNODE_TYPE = {
15+
ELEMENT: 1,
16+
COMPONENT: 2,
17+
STATELESS_COMPONENT: 3,
18+
TEXT: 4
19+
};
20+
var DIFF_TYPE = {
21+
CREATE: 1,
22+
REMOVE: 2,
23+
REPLACE: 3,
24+
UPDATE: 4
25+
};
26+
27+
var COMPONENT_ID = 'liteid';
28+
1429
var propAlias = {
1530
// svg attributes alias
1631
clipPath: 'clip-path',
@@ -43,7 +58,7 @@ var propAlias = {
4358
htmlFor: 'for',
4459
httpEquiv: 'http-equiv',
4560
// DOM property alias
46-
autoComplete: 'autocomplete',
61+
autoCompconste: 'autocompconste',
4762
autoFocus: 'autofocus',
4863
autoPlay: 'autoplay',
4964
autoSave: 'autosave',
@@ -55,20 +70,21 @@ var propAlias = {
5570
};
5671

5772
var attributesNS = {
58-
'xlink:actuate': xlink,
59-
'xlink:arcrole': xlink,
60-
'xlink:href': xlink,
61-
'xlink:role': xlink,
62-
'xlink:show': xlink,
63-
'xlink:title': xlink,
64-
'xlink:type': xlink,
65-
'xml:base': xml,
66-
'xml:lang': xml,
67-
'xml:space': xml
73+
xlinkActuate: xlink,
74+
xlinkArcrole: xlink,
75+
xlinkHref: xlink,
76+
xlinkRole: xlink,
77+
xlinkShow: xlink,
78+
xlinkTitle: xlink,
79+
xlinkType: xlink,
80+
xmlBase: xml,
81+
xmlLang: xml,
82+
xmlSpace: xml
6883
};
6984

7085
// those key must use be attributes
7186
var attrbutesConfigs = {
87+
type: TRUE,
7288
clipPath: TRUE,
7389
cx: TRUE,
7490
cy: TRUE,
@@ -129,22 +145,22 @@ var attrbutesConfigs = {
129145
*/
130146
allowFullScreen: TRUE,
131147
allowTransparency: TRUE,
132-
capture: TRUE,
148+
// capture: TRUE,
133149
charSet: TRUE,
134150
challenge: TRUE,
135151
classID: TRUE,
136152
cols: TRUE,
137153
contextMenu: TRUE,
138154
dateTime: TRUE,
139-
disabled: TRUE,
155+
// disabled: TRUE,
140156
form: TRUE,
141157
formAction: TRUE,
142158
formEncType: TRUE,
143159
formMethod: TRUE,
144160
formTarget: TRUE,
145161
frameBorder: TRUE,
146162
height: TRUE,
147-
hidden: TRUE,
163+
// hidden: TRUE,
148164
inputMode: TRUE,
149165
is: TRUE,
150166
keyParams: TRUE,
@@ -157,7 +173,7 @@ var attrbutesConfigs = {
157173
nonce: TRUE,
158174
role: TRUE,
159175
rows: TRUE,
160-
seamless: TRUE,
176+
// seamless: TRUE,
161177
size: TRUE,
162178
sizes: TRUE,
163179
srcSet: TRUE,
@@ -185,7 +201,7 @@ var attrbutesConfigs = {
185201
// itemProp, itemScope, itemType are for
186202
// Microdata support. See http://schema.org/docs/gs.html
187203
itemProp: TRUE,
188-
itemScope: TRUE,
204+
// itemScope: TRUE,
189205
itemType: TRUE,
190206
// itemID and itemRef are for Microdata support as well but
191207
// only specified in the the WHATWG spec document. See
@@ -302,21 +318,6 @@ var notBubbleEvents = {
302318
oncontextmenu: TRUE
303319
};
304320

305-
var VNODE_TYPE = {
306-
ELEMENT: 1,
307-
COMPONENT: 2,
308-
STATELESS_COMPONENT: 3,
309-
TEXT: 4
310-
};
311-
var DIFF_TYPE = {
312-
CREATE: 1,
313-
REMOVE: 2,
314-
REPLACE: 3,
315-
UPDATE: 4
316-
};
317-
318-
var COMPONENT_ID = 'liteid';
319-
320321
var isValidElement = function isValidElement(obj) {
321322
return obj != null && !!obj.vtype;
322323
};
@@ -543,6 +544,7 @@ var isStyleKey = function isStyleKey(key) {
543544
};
544545

545546
var setProp = function setProp(elem, key, value) {
547+
var originalKey = key;
546548
key = propAlias[key] || key;
547549
switch (true) {
548550
case ignoreKeys[key] === true:
@@ -556,7 +558,7 @@ var setProp = function setProp(elem, key, value) {
556558
case isInnerHTMLKey(key):
557559
value && value.__html != null && (elem.innerHTML = value.__html);
558560
break;
559-
case key in elem && attrbutesConfigs[key] !== true:
561+
case key in elem && attrbutesConfigs[originalKey] !== true:
560562
if (readOnlyProps[key] !== true) {
561563
if (key === 'title' && value == null) {
562564
value = '';
@@ -565,8 +567,9 @@ var setProp = function setProp(elem, key, value) {
565567
}
566568
break;
567569
default:
568-
value = value == null ? '' : '' + value;
569-
if (attributesNS[key] === true) {
570+
if (value == null) {
571+
elem.removeAttribute(key);
572+
} else if (attributesNS[originalKey] === true) {
570573
elem.setAttributeNS(key, value);
571574
} else {
572575
elem.setAttribute(key, value);

dist/react-lite.js

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* react-lite.js v0.0.22
2+
* react-lite.js v0.0.23
33
* (c) 2016 Jade Gu
44
* Released under the MIT License.
55
*/
@@ -15,6 +15,21 @@
1515

1616
var SVGNamespaceURI = 'http://www.w3.org/2000/svg';
1717

18+
var VNODE_TYPE = {
19+
ELEMENT: 1,
20+
COMPONENT: 2,
21+
STATELESS_COMPONENT: 3,
22+
TEXT: 4
23+
};
24+
var DIFF_TYPE = {
25+
CREATE: 1,
26+
REMOVE: 2,
27+
REPLACE: 3,
28+
UPDATE: 4
29+
};
30+
31+
var COMPONENT_ID = 'liteid';
32+
1833
var propAlias = {
1934
// svg attributes alias
2035
clipPath: 'clip-path',
@@ -47,7 +62,7 @@
4762
htmlFor: 'for',
4863
httpEquiv: 'http-equiv',
4964
// DOM property alias
50-
autoComplete: 'autocomplete',
65+
autoCompconste: 'autocompconste',
5166
autoFocus: 'autofocus',
5267
autoPlay: 'autoplay',
5368
autoSave: 'autosave',
@@ -59,20 +74,21 @@
5974
};
6075

6176
var attributesNS = {
62-
'xlink:actuate': xlink,
63-
'xlink:arcrole': xlink,
64-
'xlink:href': xlink,
65-
'xlink:role': xlink,
66-
'xlink:show': xlink,
67-
'xlink:title': xlink,
68-
'xlink:type': xlink,
69-
'xml:base': xml,
70-
'xml:lang': xml,
71-
'xml:space': xml
77+
xlinkActuate: xlink,
78+
xlinkArcrole: xlink,
79+
xlinkHref: xlink,
80+
xlinkRole: xlink,
81+
xlinkShow: xlink,
82+
xlinkTitle: xlink,
83+
xlinkType: xlink,
84+
xmlBase: xml,
85+
xmlLang: xml,
86+
xmlSpace: xml
7287
};
7388

7489
// those key must use be attributes
7590
var attrbutesConfigs = {
91+
type: TRUE,
7692
clipPath: TRUE,
7793
cx: TRUE,
7894
cy: TRUE,
@@ -133,22 +149,22 @@
133149
*/
134150
allowFullScreen: TRUE,
135151
allowTransparency: TRUE,
136-
capture: TRUE,
152+
// capture: TRUE,
137153
charSet: TRUE,
138154
challenge: TRUE,
139155
classID: TRUE,
140156
cols: TRUE,
141157
contextMenu: TRUE,
142158
dateTime: TRUE,
143-
disabled: TRUE,
159+
// disabled: TRUE,
144160
form: TRUE,
145161
formAction: TRUE,
146162
formEncType: TRUE,
147163
formMethod: TRUE,
148164
formTarget: TRUE,
149165
frameBorder: TRUE,
150166
height: TRUE,
151-
hidden: TRUE,
167+
// hidden: TRUE,
152168
inputMode: TRUE,
153169
is: TRUE,
154170
keyParams: TRUE,
@@ -161,7 +177,7 @@
161177
nonce: TRUE,
162178
role: TRUE,
163179
rows: TRUE,
164-
seamless: TRUE,
180+
// seamless: TRUE,
165181
size: TRUE,
166182
sizes: TRUE,
167183
srcSet: TRUE,
@@ -189,7 +205,7 @@
189205
// itemProp, itemScope, itemType are for
190206
// Microdata support. See http://schema.org/docs/gs.html
191207
itemProp: TRUE,
192-
itemScope: TRUE,
208+
// itemScope: TRUE,
193209
itemType: TRUE,
194210
// itemID and itemRef are for Microdata support as well but
195211
// only specified in the the WHATWG spec document. See
@@ -306,21 +322,6 @@
306322
oncontextmenu: TRUE
307323
};
308324

309-
var VNODE_TYPE = {
310-
ELEMENT: 1,
311-
COMPONENT: 2,
312-
STATELESS_COMPONENT: 3,
313-
TEXT: 4
314-
};
315-
var DIFF_TYPE = {
316-
CREATE: 1,
317-
REMOVE: 2,
318-
REPLACE: 3,
319-
UPDATE: 4
320-
};
321-
322-
var COMPONENT_ID = 'liteid';
323-
324325
var isValidElement = function isValidElement(obj) {
325326
return obj != null && !!obj.vtype;
326327
};
@@ -547,6 +548,7 @@
547548
};
548549

549550
var setProp = function setProp(elem, key, value) {
551+
var originalKey = key;
550552
key = propAlias[key] || key;
551553
switch (true) {
552554
case ignoreKeys[key] === true:
@@ -560,7 +562,7 @@
560562
case isInnerHTMLKey(key):
561563
value && value.__html != null && (elem.innerHTML = value.__html);
562564
break;
563-
case key in elem && attrbutesConfigs[key] !== true:
565+
case key in elem && attrbutesConfigs[originalKey] !== true:
564566
if (readOnlyProps[key] !== true) {
565567
if (key === 'title' && value == null) {
566568
value = '';
@@ -569,8 +571,9 @@
569571
}
570572
break;
571573
default:
572-
value = value == null ? '' : '' + value;
573-
if (attributesNS[key] === true) {
574+
if (value == null) {
575+
elem.removeAttribute(key);
576+
} else if (attributesNS[originalKey] === true) {
574577
elem.setAttributeNS(key, value);
575578
} else {
576579
elem.setAttribute(key, value);

dist/react-lite.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-lite.min.js.gz

-27 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-lite",
3-
"version": "0.0.22",
3+
"version": "0.0.23",
44
"description": "an implementation of React that optimizes for small script size",
55
"main": "dist/react-lite.common.js",
66
"jsnext:main": "src/index.js",

0 commit comments

Comments
 (0)