Skip to content

Commit

Permalink
feat(omi): update方法不再接受ignoreAttrs参数
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Aug 21, 2023
1 parent dd152cf commit 4d58307
Show file tree
Hide file tree
Showing 31 changed files with 75 additions and 106 deletions.
8 changes: 4 additions & 4 deletions packages/omi/dist/omi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ declare namespace Omi {
inject?: string[];
injection?: { [key: string]: any };

update(ignoreAttrs?: boolean, updateSelf?: boolean): void;
update(updateSelf?: boolean): void;
forceUpdate(): void;
updateProps(obj: any): void;
updateSelf(ignoreAttrs?: boolean): void;
updateSelf(): void;
fire(name: string, data?: any): void;

// Abstract methods don't infer argument types
Expand Down Expand Up @@ -153,10 +153,10 @@ declare namespace Omi {
inject?: string[];
injection?: { [key: string]: any };

update(ignoreAttrs?: boolean, updateSelf?: boolean): void;
update(updateSelf?: boolean): void;
forceUpdate(): void;
updateProps(obj: any): void;
updateSelf(ignoreAttrs?: boolean): void;
updateSelf(): void;
fire(name: string, data?: any): void;

// Abstract methods don't infer argument types
Expand Down
22 changes: 9 additions & 13 deletions packages/omi/dist/omi.dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/omi/dist/omi.dev.js.map

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions packages/omi/dist/omi.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/omi/dist/omi.esm.js.map

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions packages/omi/dist/omi.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/omi/dist/omi.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/omi/dist/omi.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/omi/dist/omi.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/omi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omi",
"version": "6.25.18",
"version": "6.25.19",
"description": "Front End Cross-Frameworks Framework.",
"main": "dist/omi.js",
"jsnext:main": "dist/omi.esm.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/omi/src/omi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ declare namespace Omi {
inject?: string[];
injection?: { [key: string]: any };

update(ignoreAttrs?: boolean, updateSelf?: boolean): void;
update(updateSelf?: boolean): void;
forceUpdate(): void;
updateProps(obj: any): void;
updateSelf(ignoreAttrs?: boolean): void;
updateSelf(): void;
fire(name: string, data?: any): void;

// Abstract methods don't infer argument types
Expand Down Expand Up @@ -153,10 +153,10 @@ declare namespace Omi {
inject?: string[];
injection?: { [key: string]: any };

update(ignoreAttrs?: boolean, updateSelf?: boolean): void;
update(updateSelf?: boolean): void;
forceUpdate(): void;
updateProps(obj: any): void;
updateSelf(ignoreAttrs?: boolean): void;
updateSelf(): void;
fire(name: string, data?: any): void;

// Abstract methods don't infer argument types
Expand Down
2 changes: 1 addition & 1 deletion packages/omi/src/omi.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const omi = {

options.root.Omi = omi
options.root.omi = omi
options.root.Omi.version = '6.25.18'
options.root.Omi.version = '6.25.19'

export default omi

Expand Down
23 changes: 7 additions & 16 deletions packages/omi/src/we-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default class WeElement extends HTMLElement {
this.isInstalled = false
}

update(ignoreAttrs, updateSelf) {
update(updateSelf) {
this._willUpdate = true
this.beforeUpdate()
this.beforeRender()
Expand All @@ -156,7 +156,7 @@ export default class WeElement extends HTMLElement {
this.shadowRoot.appendChild(this._customStyleElement)
}
}
this.attrsToProps(ignoreAttrs)
this.attrsToProps()

const rendered = this.render(this.props, this.store)
this.rendered()
Expand All @@ -172,22 +172,18 @@ export default class WeElement extends HTMLElement {
this.updated()
}

forceUpdate() {
this.update(true)
}

updateProps(obj) {
Object.keys(obj).forEach(key => {
this.props[key] = obj[key]
if (this.prevProps) {
this.prevProps[key] = obj[key]
}
})
this.forceUpdate()
this.update()
}

updateSelf(ignoreAttrs) {
this.update(ignoreAttrs, true)
updateSelf() {
this.update(true)
}

removeAttribute(key) {
Expand All @@ -214,13 +210,8 @@ export default class WeElement extends HTMLElement {
super.setAttribute(key, val)
}

attrsToProps(ignoreAttrs) {
if (
ignoreAttrs ||
(this.store && this.store.ignoreAttrs) ||
this.props.ignoreAttrs
)
return
attrsToProps() {
if (this.props.ignoreAttrs) return
const ele = this
ele.props['css'] = ele.getAttribute('css')
const attrs = this.constructor.propTypes
Expand Down
16 changes: 8 additions & 8 deletions site/docs/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"cn.css": "static/css/cn.4dd07f49.css",
"cn.css.map": "static/css/cn.4dd07f49.css.map",
"cn.js": "static/js/cn.9f57ab6e.js",
"cn.js.map": "static/js/cn.9f57ab6e.js.map",
"cn.js": "static/js/cn.651bb1e7.js",
"cn.js.map": "static/js/cn.651bb1e7.js.map",
"index.css": "static/css/index.4dd07f49.css",
"index.css.map": "static/css/index.4dd07f49.css.map",
"index.js": "static/js/index.39b7da12.js",
"index.js.map": "static/js/index.39b7da12.js.map",
"static/js/0.efa385da.chunk.js": "static/js/0.efa385da.chunk.js",
"static/js/0.efa385da.chunk.js.map": "static/js/0.efa385da.chunk.js.map",
"index.js": "static/js/index.eff19fd7.js",
"index.js.map": "static/js/index.eff19fd7.js.map",
"static/js/0.9f88e82f.chunk.js": "static/js/0.9f88e82f.chunk.js",
"static/js/0.9f88e82f.chunk.js.map": "static/js/0.9f88e82f.chunk.js.map",
"static/js/1.820f4ee6.chunk.js": "static/js/1.820f4ee6.chunk.js",
"static/js/1.820f4ee6.chunk.js.map": "static/js/1.820f4ee6.chunk.js.map",
"static/js/10.8e4de214.chunk.js": "static/js/10.8e4de214.chunk.js",
Expand All @@ -35,8 +35,8 @@
"static/js/2.1e24d7c5.chunk.js.map": "static/js/2.1e24d7c5.chunk.js.map",
"static/js/20.b4d9f9a5.chunk.js": "static/js/20.b4d9f9a5.chunk.js",
"static/js/20.b4d9f9a5.chunk.js.map": "static/js/20.b4d9f9a5.chunk.js.map",
"static/js/21.19154067.chunk.js": "static/js/21.19154067.chunk.js",
"static/js/21.19154067.chunk.js.map": "static/js/21.19154067.chunk.js.map",
"static/js/21.e36975b6.chunk.js": "static/js/21.e36975b6.chunk.js",
"static/js/21.e36975b6.chunk.js.map": "static/js/21.e36975b6.chunk.js.map",
"static/js/22.5d6510e9.chunk.js": "static/js/22.5d6510e9.chunk.js",
"static/js/22.5d6510e9.chunk.js.map": "static/js/22.5d6510e9.chunk.js.map",
"static/js/23.3388824e.chunk.js": "static/js/23.3388824e.chunk.js",
Expand Down
2 changes: 1 addition & 1 deletion site/docs/cn.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="shortcut icon" href="./favicon.ico"><link rel="stylesheet" href="./highlight/prism.css"><style>*{-webkit-tap-highlight-color:rgba(255,255,255,0);-moz-user-focus:none}</style><title>OMI - Front End Cross-Frameworks Framework</title><link href="./static/css/cn.4dd07f49.css" rel="stylesheet"></head><body><script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script><script src="./highlight/prism.js"></script><script src="./js/remarkable.min.js"></script><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/cn.9f57ab6e.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="shortcut icon" href="./favicon.ico"><link rel="stylesheet" href="./highlight/prism.css"><style>*{-webkit-tap-highlight-color:rgba(255,255,255,0);-moz-user-focus:none}</style><title>OMI - Front End Cross-Frameworks Framework</title><link href="./static/css/cn.4dd07f49.css" rel="stylesheet"></head><body><script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script><script src="./highlight/prism.js"></script><script src="./js/remarkable.min.js"></script><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/cn.651bb1e7.js"></script></body></html>
2 changes: 1 addition & 1 deletion site/docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="shortcut icon" href="./favicon.ico"><link rel="stylesheet" href="./highlight/prism.css"><style>*{-webkit-tap-highlight-color:rgba(255,255,255,0);-moz-user-focus:none}</style><title>OMI - Front End Cross-Frameworks Framework</title><link href="./static/css/index.4dd07f49.css" rel="stylesheet"></head><body><script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script><script src="./highlight/prism.js"></script><script src="./js/remarkable.min.js"></script><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/index.39b7da12.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="shortcut icon" href="./favicon.ico"><link rel="stylesheet" href="./highlight/prism.css"><style>*{-webkit-tap-highlight-color:rgba(255,255,255,0);-moz-user-focus:none}</style><title>OMI - Front End Cross-Frameworks Framework</title><link href="./static/css/index.4dd07f49.css" rel="stylesheet"></head><body><script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script><script src="./highlight/prism.js"></script><script src="./js/remarkable.min.js"></script><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/index.eff19fd7.js"></script></body></html>
Loading

0 comments on commit 4d58307

Please sign in to comment.