Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
qitmac000408 authored and qitmac000408 committed Aug 2, 2017
1 parent bf3e70d commit 2514d0f
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 75 deletions.
67 changes: 25 additions & 42 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,49 @@ module.exports = {
"node": true
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"globals": {
"module": true,
"define": true,
"expect": true,
"describe": true,
"it": true,
"webpackIsomorphicTools": true,
"__CLIENT__": true,
"__SERVER__": true,
"__DEVELOPMENT__": true,
"__DEVTOOLS__": true,
"__INITIAL_STATE__": true
"exports": true
},
"plugins": [
"react"
],
"rules": {
"indent": [
"error",
4
],
"strict": 0,
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
"comma-dangle": [2, "only-multiline"],
"eqeqeq": ["error", "always"],
"no-alert": "error",
"no-eval": "error",
"guard-for-in": "error",
"no-new-func": "error",
"no-with": "error",
"for-direction": "error",
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"curly": "error",
"brace-style": ["error", "1tbs"],
"no-bitwise": "error",
"no-extend-native": "error",
"array-callback-return": "error",
"no-useless-call": "error",
"no-sequences": "error",
"no-restricted-properties": [2, {
"property": "localStorage"
}],
"no-unmodified-loop-condition": "error",
"no-underscore-dangle": ["off"],
"react/prefer-stateless-function": ["off"],
"semi": [
"error",
"always"
],
"max-len": ["error", 200, 4],
"one-var": ["off"],
"no-confusing-arrow": "off",
"react/jsx-no-bind": ["off"],
"react/jsx-indent": [2, 4],
"react/jsx-indent-props": [2, 4],
"react/jsx-boolean-value": ["off"],
"eol-last": 0,
"no-param-reassign": [1],
"no-template-curly-in-string": "error",
"radix": "error"
"react/jsx-boolean-value": ["off"]
}
};
};


21 changes: 13 additions & 8 deletions dist/React.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* by 司徒正美 Copyright 2017-07-28
* by 司徒正美 Copyright 2017-08-02
* 兼容yo-router
*/

Expand Down Expand Up @@ -731,7 +731,7 @@ function dispatchEvent(e) {

var captured = bubble + "capture";

scheduler.run();
//scheduler.run();
triggerEventFlow(paths, captured, e);

if (!e._stopPropagation) {
Expand Down Expand Up @@ -766,7 +766,7 @@ function triggerEventFlow(paths, prop, e) {
}
}

function addGlobalEventListener(name) {
function addGlobalEvent(name) {
if (!globalEvents[name]) {
globalEvents[name] = true;
addEvent(document, name, dispatchEvent);
Expand Down Expand Up @@ -894,7 +894,7 @@ var eventSystem = extend({
isEventName: isEventName,
isTouch: isTouch,
dispatchEvent: dispatchEvent,
addGlobalEventListener: addGlobalEventListener,
addGlobalEvent: addGlobalEvent,
addEvent: addEvent,
getBrowserName: getBrowserName,
SyntheticEvent: SyntheticEvent
Expand Down Expand Up @@ -1353,7 +1353,7 @@ var propHooks = {
if (!lastProps[name]) {
//添加全局监听事件
var _name = getBrowserName(name);
addGlobalEventListener(_name);
addGlobalEvent(_name);
var hook = eventHooks[_name];
if (hook) {
hook(dom, name);
Expand Down Expand Up @@ -1522,7 +1522,7 @@ function updateOptionsMore(options$$1, n, propValue) {
}
} catch (e) {
/* istanbul ignore next */
console.warn("<select multiple=\"true\"> 的value应该对应一个字符串数组"); // eslint-disable-line
console.warn('<select multiple="true"> 的value应该对应一个字符串数组'); // eslint-disable-line
}
for (var _i = 0; _i < n; _i++) {
var option = options$$1[_i];
Expand Down Expand Up @@ -1589,7 +1589,7 @@ try {
var id = getID(a);
this.map[id] = v;
},
"delete": function _delete(a) {
delete: function _delete(a) {
var id = getID(a);
delete this.map[id];
}
Expand Down Expand Up @@ -2014,7 +2014,6 @@ function reRenderComponent(instance) {
instance._disableSetState = false;
return dom;
}

function alignVnodes(vnode, newVnode, node, parentContext) {
var newNode = node;
//eslint-disable-next-line
Expand All @@ -2025,6 +2024,12 @@ function alignVnodes(vnode, newVnode, node, parentContext) {
//replace
disposeVnode(vnode);
newNode = mountVnode(newVnode, parentContext);
if (newVnode._instance && scheduler.count) {
// schedulerID = setTimeout(function(){
scheduler.run();
// schedulerID = null
// })
}
var p = node.parentNode;
if (p) {
p.replaceChild(newNode, node);
Expand Down
19 changes: 12 additions & 7 deletions dist/ReactIE.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* 兼容IE6-8的版本,有问题请加QQ 370262116 by 司徒正美 Copyright 2017-07-28
* 兼容IE6-8的版本,有问题请加QQ 370262116 by 司徒正美 Copyright 2017-08-02
*/

(function (global, factory) {
Expand Down Expand Up @@ -1018,7 +1018,7 @@ function dispatchEvent(e) {

var captured = bubble + "capture";

scheduler.run();
//scheduler.run();
triggerEventFlow(paths, captured, e);

if (!e._stopPropagation) {
Expand Down Expand Up @@ -1053,7 +1053,7 @@ function triggerEventFlow(paths, prop, e) {
}
}

function addGlobalEventListener(name) {
function addGlobalEvent(name) {
if (!globalEvents[name]) {
globalEvents[name] = true;
addEvent(document, name, dispatchEvent);
Expand Down Expand Up @@ -1339,7 +1339,7 @@ var propHooks = {
if (!lastProps[name]) {
//添加全局监听事件
var _name = getBrowserName(name);
addGlobalEventListener(_name);
addGlobalEvent(_name);
var hook = eventHooks[_name];
if (hook) {
hook(dom, name);
Expand Down Expand Up @@ -1508,7 +1508,7 @@ function updateOptionsMore(options$$1, n, propValue) {
}
} catch (e) {
/* istanbul ignore next */
console.warn("<select multiple=\"true\"> 的value应该对应一个字符串数组"); // eslint-disable-line
console.warn('<select multiple="true"> 的value应该对应一个字符串数组'); // eslint-disable-line
}
for (var _i = 0; _i < n; _i++) {
var option = options$$1[_i];
Expand Down Expand Up @@ -1575,7 +1575,7 @@ try {
var id = getID(a);
this.map[id] = v;
},
"delete": function _delete(a) {
delete: function _delete(a) {
var id = getID(a);
delete this.map[id];
}
Expand Down Expand Up @@ -2000,7 +2000,6 @@ function reRenderComponent(instance) {
instance._disableSetState = false;
return dom;
}

function alignVnodes(vnode, newVnode, node, parentContext) {
var newNode = node;
//eslint-disable-next-line
Expand All @@ -2011,6 +2010,12 @@ function alignVnodes(vnode, newVnode, node, parentContext) {
//replace
disposeVnode(vnode);
newNode = mountVnode(newVnode, parentContext);
if (newVnode._instance && scheduler.count) {
// schedulerID = setTimeout(function(){
scheduler.run();
// schedulerID = null
// })
}
var p = node.parentNode;
if (p) {
p.replaceChild(newNode, node);
Expand Down
17 changes: 11 additions & 6 deletions dist/ReactShim.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* 此版本要求浏览器支持Map对象,没有createClass, createFactory, PropTypes, isValidElement,
* unmountComponentAtNode,unstable_renderSubtreeIntoContainer
* QQ 370262116 by 司徒正美 Copyright 2017-07-28
* QQ 370262116 by 司徒正美 Copyright 2017-08-02
*/

(function (global, factory) {
Expand Down Expand Up @@ -798,7 +798,7 @@ function dispatchEvent(e) {

var captured = bubble + "capture";

scheduler.run();
//scheduler.run();
triggerEventFlow(paths, captured, e);

if (!e._stopPropagation) {
Expand Down Expand Up @@ -833,7 +833,7 @@ function triggerEventFlow(paths, prop, e) {
}
}

function addGlobalEventListener(name) {
function addGlobalEvent(name) {
if (!globalEvents[name]) {
globalEvents[name] = true;
addEvent(document, name, dispatchEvent);
Expand Down Expand Up @@ -1119,7 +1119,7 @@ var propHooks = {
if (!lastProps[name]) {
//添加全局监听事件
var _name = getBrowserName(name);
addGlobalEventListener(_name);
addGlobalEvent(_name);
var hook = eventHooks[_name];
if (hook) {
hook(dom, name);
Expand Down Expand Up @@ -1288,7 +1288,7 @@ function updateOptionsMore(options$$1, n, propValue) {
}
} catch (e) {
/* istanbul ignore next */
console.warn("<select multiple=\"true\"> 的value应该对应一个字符串数组"); // eslint-disable-line
console.warn('<select multiple="true"> 的value应该对应一个字符串数组'); // eslint-disable-line
}
for (var _i = 0; _i < n; _i++) {
var option = options$$1[_i];
Expand Down Expand Up @@ -1722,7 +1722,6 @@ function reRenderComponent(instance) {
instance._disableSetState = false;
return dom;
}

function alignVnodes(vnode, newVnode, node, parentContext) {
var newNode = node;
//eslint-disable-next-line
Expand All @@ -1733,6 +1732,12 @@ function alignVnodes(vnode, newVnode, node, parentContext) {
//replace
disposeVnode(vnode);
newNode = mountVnode(newVnode, parentContext);
if (newVnode._instance && scheduler.count) {
// schedulerID = setTimeout(function(){
scheduler.run();
// schedulerID = null
// })
}
var p = node.parentNode;
if (p) {
p.replaceChild(newNode, node);
Expand Down
2 changes: 1 addition & 1 deletion src/createElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function Vnode(type, props, key, ref, vtype, checkProps, owner) {
}

Vnode.prototype = {
getDOMNode: function() {
getDOMNode: function () {
return this._hostNode || null;
},

Expand Down
15 changes: 9 additions & 6 deletions src/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function genVnodes(vnode, container, hostParent, parentContext) {
var nodes = getNodes(container);
var prevRendered = null;
//eslint-disable-next-line
for (var i = 0, el; (el = nodes[i++]); ) {
for (var i = 0, el; (el = nodes[i++]);) {
if (el.getAttribute && el.getAttribute("data-reactroot") !== null) {
prevRendered = el;
} else {
Expand Down Expand Up @@ -182,7 +182,7 @@ function mountElement(vnode, parentContext, prevRendered) {
}

if (vnode.ref) {
scheduler.add(function() {
scheduler.add(function () {
vnode.ref(dom);
});
}
Expand Down Expand Up @@ -271,7 +271,7 @@ function mountComponent(vnode, parentContext, prevRendered) {
}

if (vnode.ref) {
scheduler.add(function() {
scheduler.add(function () {
vnode.ref(instance);
});
}
Expand Down Expand Up @@ -326,7 +326,7 @@ function refreshComponent(instance) {
reRenderComponent(instance);

instance._forceUpdate = false;
instance._pendingCallbacks.splice(0).forEach(function(fn) {
instance._pendingCallbacks.splice(0).forEach(function (fn) {
fn.call(instance);
});
}
Expand All @@ -338,9 +338,9 @@ function reRenderComponent(instance) {
var node = instanceMap.get(instance);

if (!instance._hasDidMount) {
scheduler.addAndRun(function() {
scheduler.addAndRun(function () {
instance._forceUpdate = false;
instance._pendingCallbacks.splice(0).forEach(function(fn) {
instance._pendingCallbacks.splice(0).forEach(function (fn) {
fn.call(instance);
});
});
Expand Down Expand Up @@ -409,6 +409,9 @@ export function alignVnodes(vnode, newVnode, node, parentContext) {
//replace
disposeVnode(vnode);
newNode = mountVnode(newVnode, parentContext);
if (newVnode._instance && scheduler.count) {
scheduler.run()
}
var p = node.parentNode;
if (p) {
p.replaceChild(newNode, node);
Expand Down
4 changes: 2 additions & 2 deletions src/diffProps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { patchStyle } from "./style";

import {
addGlobalEventListener,
addGlobalEvent,
getBrowserName,
isEventName,
eventHooks
Expand Down Expand Up @@ -194,7 +194,7 @@ var propHooks = {
if (!lastProps[name]) {
//添加全局监听事件
var _name = getBrowserName(name);
addGlobalEventListener(_name);
addGlobalEvent(_name);
var hook = eventHooks[_name];
if (hook) {
hook(dom, name);
Expand Down
Loading

0 comments on commit 2514d0f

Please sign in to comment.