Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(image): method duplicate execute #2362

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions src/image/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,43 @@ exports[`image :base 1`] = `
<t-image>
<wx-view
ariaHidden="{{false}}"
class="class t-class t-image t-image__mask t-image--failed t-image--shape-square"
class="class t-class t-image t-image__mask t-image--loading t-image--shape-square"
style=""
>
<wx-view
class="t-class-load"
style="font-size: 44rpx"
<t-loading
tClass="t-class-load"
tClassText="t-image--loading-text"
>
<t-icon>
<wx-view
class="class t-class t-loading t-loading--horizontal"
style="width: 44rpx; height: 44rpx; color: inherit;"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel="加载失败"
ariaLabel="加载中"
ariaRole="img"
class="t-icon class t-class"
style=""
bind:tap="onTap"
class="t-class-indicator t-loading__spinner t-loading__spinner--dots "
style="width: 44rpx; height: 44rpx; color: inherit; animation-duration: 0.8s; animation-play-state: running;"
>
<wx-label
class="t-icon-close t-icon-base"
<wx-view
class="t-loading__dot"
style="animation-duration: 0.8s; animation-delay:0s; animation-play-state: running;"
/>
<wx-view
class="t-loading__dot"
style="animation-duration: 0.8s; animation-delay:0.26666666666666666s; animation-play-state: running;"
/>
<wx-view
class="t-loading__dot"
style="animation-duration: 0.8s; animation-delay:0.5333333333333333s; animation-play-state: running;"
/>
</wx-view>
</t-icon>
</wx-view>
<wx-view
ariaHidden="{{true}}"
ariaLabel=""
class="t-loading__text t-loading__text--horizontal t-class-text"
/>
</wx-view>
</t-loading>
</wx-view>
<wx-image
ariaHidden="{{true}}"
Expand Down
9 changes: 0 additions & 9 deletions src/image/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ export default class Image extends SuperComponent {

preSrc = ''; // 保留上一次的src,防止在src相同时重复update

lifetimes = {
attached() {
const { width, height } = this.data;

this.update();
this.calcSize(width, height);
},
};

observers = {
src() {
if (this.preSrc === this.properties.src) return;
Expand Down