auto bind this
This commit is contained in:
parent
cdca3d1311
commit
80f74aad76
|
@ -41,6 +41,7 @@ export default {
|
|||
}]
|
||||
],
|
||||
plugins : [
|
||||
'transform-class-properties',
|
||||
["transform-react-jsx", { "pragma":"Omi.h" }]
|
||||
]
|
||||
})
|
||||
|
|
|
@ -328,7 +328,7 @@
|
|||
var items = [];
|
||||
|
||||
function enqueueRender(component) {
|
||||
if (!component._dirty && (component._dirty = true) && items.push(component) == 1) {
|
||||
if (items.push(component) == 1) {
|
||||
(options.debounceRendering || defer)(rerender);
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +340,7 @@
|
|||
var element = void 0;
|
||||
while (p = list.pop()) {
|
||||
element = p.base;
|
||||
if (p._dirty) renderComponent(p);
|
||||
renderComponent(p);
|
||||
}
|
||||
if (!list.length) {
|
||||
if (options.componentChange) options.componentChange(p, element);
|
||||
|
@ -929,7 +929,7 @@
|
|||
}
|
||||
|
||||
var appendClass = g1.replace(/(\s*)$/, '') + prefix + g2;
|
||||
var prependClass = prefix + ' ' + g1.trim() + g2;
|
||||
//let prependClass = prefix + ' ' + g1.trim() + g2;
|
||||
|
||||
return appendClass + g3;
|
||||
//return appendClass + ',' + prependClass + g3;
|
||||
|
@ -1087,7 +1087,6 @@
|
|||
}
|
||||
|
||||
component.prevProps = component.prevState = component.prevContext = component.nextBase = null;
|
||||
component._dirty = false;
|
||||
|
||||
if (!skip) {
|
||||
rendered = component.render(props, state, context);
|
||||
|
@ -1292,7 +1291,6 @@
|
|||
* }
|
||||
*/
|
||||
function Component(props, context) {
|
||||
this._dirty = true;
|
||||
|
||||
/** @public
|
||||
* @type {object}
|
||||
|
@ -1409,7 +1407,7 @@
|
|||
}
|
||||
if (vnode.componentWillMount) vnode.componentWillMount();
|
||||
if (vnode.install) vnode.install();
|
||||
var rendered = vnode.render();
|
||||
var rendered = vnode.render(vnode.props, vnode.state, vnode.context);
|
||||
if (vnode.style) {
|
||||
addScopedAttr(rendered, vnode.style(), '_style_' + vnode._id, vnode);
|
||||
}
|
||||
|
@ -1461,7 +1459,7 @@
|
|||
instances: instances
|
||||
};
|
||||
|
||||
root.Omi.version = '3.0.0';
|
||||
root.Omi.version = '3.0.2';
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
|
@ -1494,19 +1492,22 @@
|
|||
_inherits(App, _Component2);
|
||||
|
||||
function App() {
|
||||
var _temp, _this2, _ret;
|
||||
|
||||
_classCallCheck(this, App);
|
||||
|
||||
return _possibleConstructorReturn(this, _Component2.apply(this, arguments));
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this2 = _possibleConstructorReturn(this, _Component2.call.apply(_Component2, [this].concat(args))), _this2), _this2.handleClick = function (e) {
|
||||
_this2.name = 'Hello Omi !';
|
||||
_this2.update();
|
||||
}, _temp), _possibleConstructorReturn(_this2, _ret);
|
||||
}
|
||||
|
||||
App.prototype.install = function install() {
|
||||
this.name = 'Omi';
|
||||
this.handleClick = this.handleClick.bind(this);
|
||||
};
|
||||
|
||||
App.prototype.handleClick = function handleClick(e) {
|
||||
this.name = 'Hello Omi !';
|
||||
this.update();
|
||||
};
|
||||
|
||||
App.prototype.style = function style() {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,10 +9,9 @@ class Hello extends Component {
|
|||
class App extends Component {
|
||||
install() {
|
||||
this.name = 'Omi'
|
||||
this.handleClick = this.handleClick.bind(this)
|
||||
}
|
||||
|
||||
handleClick(e) {
|
||||
handleClick = (e) => {
|
||||
this.name = 'Hello Omi !'
|
||||
this.update()
|
||||
}
|
||||
|
|
295
package.json
295
package.json
|
@ -1,147 +1,148 @@
|
|||
{
|
||||
"name": "omi",
|
||||
"version": "3.0.2",
|
||||
"description": "Omi === Preact + Scoped CSS + Store System + Native Support in 3kb javascript.",
|
||||
"main": "dist/omi.js",
|
||||
"jsnext:main": "dist/omi.esm.js",
|
||||
"module": "dist/omi.esm.js",
|
||||
"dev:main": "dist/omi.dev.js",
|
||||
"minified:main": "dist/omi.min.js",
|
||||
"types": "dist/omi.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist/ devtools.js devtools.js.map debug.js debug.js.map test/ts/**/*.js",
|
||||
"copy-flow-definition": "copyfiles -f src/omi.js.flow dist",
|
||||
"copy-typescript-definition": "copyfiles -f src/omi.d.ts dist",
|
||||
"build": "npm-run-all --silent clean transpile copy-flow-definition copy-typescript-definition strip optimize minify size",
|
||||
"flow": "flow",
|
||||
"todo": "rollup -c config/rollup.example.js --watch",
|
||||
"store": "rollup -c config/rollup.example.js --watch",
|
||||
"omi-tap": "rollup -c config/rollup.example.js --watch",
|
||||
"simple": "rollup -c config/rollup.example.js --watch",
|
||||
"transpile:main": "rollup -c config/rollup.config.js",
|
||||
"transpile:devtools": "rollup -c config/rollup.config.devtools.js",
|
||||
"transpile:esm": "rollup -c config/rollup.config.esm.js",
|
||||
"transpile:debug": "babel debug/ -o debug.js -s",
|
||||
"transpile": "npm-run-all transpile:main transpile:esm transpile:devtools transpile:debug",
|
||||
"optimize": "uglifyjs dist/omi.dev.js -c conditionals=false,sequences=false,loops=false,join_vars=false,collapse_vars=false --pure-funcs=Object.defineProperty --mangle-props --mangle-regex=\"/^(_|normalizedNodeName|nextBase|prev[CPS]|_parentC)/\" --name-cache config/properties.json -b width=120,quote_style=3 -o dist/omi.js -p relative --in-source-map dist/omi.dev.js.map --source-map dist/omi.js.map",
|
||||
"minify": "uglifyjs dist/omi.js -c collapse_vars,evaluate,screw_ie8,unsafe,loops=false,keep_fargs=false,pure_getters,unused,dead_code -m -o dist/omi.min.js -p relative --in-source-map dist/omi.js.map --source-map dist/omi.min.js.map",
|
||||
"strip:main": "jscodeshift --run-in-band -s -t config/codemod-strip-tdz.js dist/omi.dev.js && jscodeshift --run-in-band -s -t config/codemod-const.js dist/omi.dev.js && jscodeshift --run-in-band -s -t config/codemod-let-name.js dist/omi.dev.js",
|
||||
"strip:esm": "jscodeshift --run-in-band -s -t config/codemod-strip-tdz.js dist/omi.esm.js && jscodeshift --run-in-band -s -t config/codemod-const.js dist/omi.esm.js && jscodeshift --run-in-band -s -t config/codemod-let-name.js dist/omi.esm.js",
|
||||
"strip": "npm-run-all strip:main strip:esm",
|
||||
"size": "node -e \"process.stdout.write('gzip size: ')\" && gzip-size --raw dist/omi.min.js",
|
||||
"test": "npm-run-all lint --parallel test:mocha test:karma test:ts test:flow test:size",
|
||||
"fix": "eslint src --fix",
|
||||
"test:flow": "flow check",
|
||||
"test:ts": "tsc -p test/ts/ && mocha --require babel-register test/ts/**/*-test.js",
|
||||
"test:mocha": "mocha --recursive --require babel-register test/shared test/node",
|
||||
"test:karma": "karma start test/karma.conf.js --single-run",
|
||||
"test:mocha:watch": "npm run test:mocha -- --watch",
|
||||
"test:karma:watch": "npm run test:karma -- no-single-run",
|
||||
"test:size": "bundlesize",
|
||||
"lint": "eslint debug devtools src test",
|
||||
"prepublishOnly": "npm run build",
|
||||
"smart-release": "npm run build && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish",
|
||||
"release": "cross-env npm run smart-release"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "./config/eslint-config.js"
|
||||
},
|
||||
"typings": "./dist/omi.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/AlloyTeam/omi.git"
|
||||
},
|
||||
"files": [
|
||||
"devtools",
|
||||
"debug",
|
||||
"src",
|
||||
"dist",
|
||||
"devtools.js",
|
||||
"devtools.js.map",
|
||||
"debug.js",
|
||||
"debug.js.map",
|
||||
"typings.json"
|
||||
],
|
||||
"keywords": [
|
||||
"omi",
|
||||
"preact",
|
||||
"react",
|
||||
"virtual dom",
|
||||
"vdom",
|
||||
"components",
|
||||
"virtual",
|
||||
"dom"
|
||||
],
|
||||
"author": "dntzhang <dntzhang@qq.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/AlloyTeam/omi/issues"
|
||||
},
|
||||
"homepage": "https://github.com/AlloyTeam/omi",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.1.2",
|
||||
"@types/mocha": "^5.0.0",
|
||||
"@types/node": "^9.4.7",
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-core": "^6.24.1",
|
||||
"babel-eslint": "^8.2.2",
|
||||
"babel-loader": "^7.0.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.23.0",
|
||||
"babel-plugin-transform-react-jsx": "^6.24.1",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"bundlesize": "^0.17.0",
|
||||
"chai": "^4.1.2",
|
||||
"copyfiles": "^2.0.0",
|
||||
"core-js": "^2.4.1",
|
||||
"coveralls": "^3.0.0",
|
||||
"cross-env": "^5.1.4",
|
||||
"diff": "^3.0.0",
|
||||
"eslint": "^4.18.2",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"flow-bin": "^0.67.1",
|
||||
"gzip-size-cli": "^2.0.0",
|
||||
"istanbul-instrumenter-loader": "^3.0.0",
|
||||
"jscodeshift": "^0.5.0",
|
||||
"karma": "^2.0.0",
|
||||
"karma-babel-preprocessor": "^7.0.0",
|
||||
"karma-chai-sinon": "^0.1.5",
|
||||
"karma-chrome-launcher": "^2.0.0",
|
||||
"karma-coverage": "^1.0.0",
|
||||
"karma-mocha": "^1.1.1",
|
||||
"karma-mocha-reporter": "^2.0.4",
|
||||
"karma-sauce-launcher": "^1.1.0",
|
||||
"karma-sinon": "^1.0.5",
|
||||
"karma-source-map-support": "^1.2.0",
|
||||
"karma-sourcemap-loader": "^0.3.6",
|
||||
"karma-webpack": "^3.0.0",
|
||||
"mocha": "^5.0.4",
|
||||
"npm-run-all": "^4.0.0",
|
||||
"rimraf": "^2.5.3",
|
||||
"rollup": "^0.57.1",
|
||||
"rollup-plugin-babel": "^3.0.2",
|
||||
"rollup-plugin-license": "^0.6.0",
|
||||
"rollup-plugin-memory": "^3.0.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"sinon": "^4.4.2",
|
||||
"sinon-chai": "^3.0.0",
|
||||
"typescript": "^2.8.1",
|
||||
"uglify-js": "^2.7.5",
|
||||
"webpack": "^4.3.0"
|
||||
},
|
||||
"greenkeeper": {
|
||||
"ignore": [
|
||||
"babel-cli",
|
||||
"babel-core",
|
||||
"babel-eslint",
|
||||
"babel-loader",
|
||||
"jscodeshift",
|
||||
"rollup-plugin-babel"
|
||||
]
|
||||
},
|
||||
"bundlesize": [
|
||||
{
|
||||
"path": "./dist/omi.min.js",
|
||||
"threshold": "4Kb"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"name": "omi",
|
||||
"version": "3.0.2",
|
||||
"description": "Omi === Preact + Scoped CSS + Store System + Native Support in 3kb javascript.",
|
||||
"main": "dist/omi.js",
|
||||
"jsnext:main": "dist/omi.esm.js",
|
||||
"module": "dist/omi.esm.js",
|
||||
"dev:main": "dist/omi.dev.js",
|
||||
"minified:main": "dist/omi.min.js",
|
||||
"types": "dist/omi.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist/ devtools.js devtools.js.map debug.js debug.js.map test/ts/**/*.js",
|
||||
"copy-flow-definition": "copyfiles -f src/omi.js.flow dist",
|
||||
"copy-typescript-definition": "copyfiles -f src/omi.d.ts dist",
|
||||
"build": "npm-run-all --silent clean transpile copy-flow-definition copy-typescript-definition strip optimize minify size",
|
||||
"flow": "flow",
|
||||
"todo": "rollup -c config/rollup.example.js --watch",
|
||||
"store": "rollup -c config/rollup.example.js --watch",
|
||||
"omi-tap": "rollup -c config/rollup.example.js --watch",
|
||||
"simple": "rollup -c config/rollup.example.js --watch",
|
||||
"transpile:main": "rollup -c config/rollup.config.js",
|
||||
"transpile:devtools": "rollup -c config/rollup.config.devtools.js",
|
||||
"transpile:esm": "rollup -c config/rollup.config.esm.js",
|
||||
"transpile:debug": "babel debug/ -o debug.js -s",
|
||||
"transpile": "npm-run-all transpile:main transpile:esm transpile:devtools transpile:debug",
|
||||
"optimize": "uglifyjs dist/omi.dev.js -c conditionals=false,sequences=false,loops=false,join_vars=false,collapse_vars=false --pure-funcs=Object.defineProperty --mangle-props --mangle-regex=\"/^(_|normalizedNodeName|nextBase|prev[CPS]|_parentC)/\" --name-cache config/properties.json -b width=120,quote_style=3 -o dist/omi.js -p relative --in-source-map dist/omi.dev.js.map --source-map dist/omi.js.map",
|
||||
"minify": "uglifyjs dist/omi.js -c collapse_vars,evaluate,screw_ie8,unsafe,loops=false,keep_fargs=false,pure_getters,unused,dead_code -m -o dist/omi.min.js -p relative --in-source-map dist/omi.js.map --source-map dist/omi.min.js.map",
|
||||
"strip:main": "jscodeshift --run-in-band -s -t config/codemod-strip-tdz.js dist/omi.dev.js && jscodeshift --run-in-band -s -t config/codemod-const.js dist/omi.dev.js && jscodeshift --run-in-band -s -t config/codemod-let-name.js dist/omi.dev.js",
|
||||
"strip:esm": "jscodeshift --run-in-band -s -t config/codemod-strip-tdz.js dist/omi.esm.js && jscodeshift --run-in-band -s -t config/codemod-const.js dist/omi.esm.js && jscodeshift --run-in-band -s -t config/codemod-let-name.js dist/omi.esm.js",
|
||||
"strip": "npm-run-all strip:main strip:esm",
|
||||
"size": "node -e \"process.stdout.write('gzip size: ')\" && gzip-size --raw dist/omi.min.js",
|
||||
"test": "npm-run-all lint --parallel test:mocha test:karma test:ts test:flow test:size",
|
||||
"fix": "eslint src --fix",
|
||||
"test:flow": "flow check",
|
||||
"test:ts": "tsc -p test/ts/ && mocha --require babel-register test/ts/**/*-test.js",
|
||||
"test:mocha": "mocha --recursive --require babel-register test/shared test/node",
|
||||
"test:karma": "karma start test/karma.conf.js --single-run",
|
||||
"test:mocha:watch": "npm run test:mocha -- --watch",
|
||||
"test:karma:watch": "npm run test:karma -- no-single-run",
|
||||
"test:size": "bundlesize",
|
||||
"lint": "eslint debug devtools src test",
|
||||
"prepublishOnly": "npm run build",
|
||||
"smart-release": "npm run build && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish",
|
||||
"release": "cross-env npm run smart-release"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "./config/eslint-config.js"
|
||||
},
|
||||
"typings": "./dist/omi.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/AlloyTeam/omi.git"
|
||||
},
|
||||
"files": [
|
||||
"devtools",
|
||||
"debug",
|
||||
"src",
|
||||
"dist",
|
||||
"devtools.js",
|
||||
"devtools.js.map",
|
||||
"debug.js",
|
||||
"debug.js.map",
|
||||
"typings.json"
|
||||
],
|
||||
"keywords": [
|
||||
"omi",
|
||||
"preact",
|
||||
"react",
|
||||
"virtual dom",
|
||||
"vdom",
|
||||
"components",
|
||||
"virtual",
|
||||
"dom"
|
||||
],
|
||||
"author": "dntzhang <dntzhang@qq.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/AlloyTeam/omi/issues"
|
||||
},
|
||||
"homepage": "https://github.com/AlloyTeam/omi",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.1.2",
|
||||
"@types/mocha": "^5.0.0",
|
||||
"@types/node": "^9.4.7",
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-core": "^6.24.1",
|
||||
"babel-eslint": "^8.2.2",
|
||||
"babel-loader": "^7.0.0",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.23.0",
|
||||
"babel-plugin-transform-react-jsx": "^6.24.1",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"bundlesize": "^0.17.0",
|
||||
"chai": "^4.1.2",
|
||||
"copyfiles": "^2.0.0",
|
||||
"core-js": "^2.4.1",
|
||||
"coveralls": "^3.0.0",
|
||||
"cross-env": "^5.1.4",
|
||||
"diff": "^3.0.0",
|
||||
"eslint": "^4.18.2",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"flow-bin": "^0.67.1",
|
||||
"gzip-size-cli": "^2.0.0",
|
||||
"istanbul-instrumenter-loader": "^3.0.0",
|
||||
"jscodeshift": "^0.5.0",
|
||||
"karma": "^2.0.0",
|
||||
"karma-babel-preprocessor": "^7.0.0",
|
||||
"karma-chai-sinon": "^0.1.5",
|
||||
"karma-chrome-launcher": "^2.0.0",
|
||||
"karma-coverage": "^1.0.0",
|
||||
"karma-mocha": "^1.1.1",
|
||||
"karma-mocha-reporter": "^2.0.4",
|
||||
"karma-sauce-launcher": "^1.1.0",
|
||||
"karma-sinon": "^1.0.5",
|
||||
"karma-source-map-support": "^1.2.0",
|
||||
"karma-sourcemap-loader": "^0.3.6",
|
||||
"karma-webpack": "^3.0.0",
|
||||
"mocha": "^5.0.4",
|
||||
"npm-run-all": "^4.0.0",
|
||||
"rimraf": "^2.5.3",
|
||||
"rollup": "^0.57.1",
|
||||
"rollup-plugin-babel": "^3.0.2",
|
||||
"rollup-plugin-license": "^0.6.0",
|
||||
"rollup-plugin-memory": "^3.0.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"sinon": "^4.4.2",
|
||||
"sinon-chai": "^3.0.0",
|
||||
"typescript": "^2.8.1",
|
||||
"uglify-js": "^2.7.5",
|
||||
"webpack": "^4.3.0"
|
||||
},
|
||||
"greenkeeper": {
|
||||
"ignore": [
|
||||
"babel-cli",
|
||||
"babel-core",
|
||||
"babel-eslint",
|
||||
"babel-loader",
|
||||
"jscodeshift",
|
||||
"rollup-plugin-babel"
|
||||
]
|
||||
},
|
||||
"bundlesize": [
|
||||
{
|
||||
"path": "./dist/omi.min.js",
|
||||
"threshold": "4Kb"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ export function render(vnode, parent, merge) {
|
|||
}
|
||||
if (vnode.componentWillMount) vnode.componentWillMount();
|
||||
if (vnode.install) vnode.install();
|
||||
const rendered = vnode.render();
|
||||
const rendered = vnode.render(vnode.props, vnode.state, vnode.context);
|
||||
if (vnode.style){
|
||||
addScopedAttr(rendered,vnode.style(),'_style_'+vnode._id,vnode);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue