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

invalidate $$props or $$restProps only when there's changes #5123

Merged
merged 3 commits into from
Jul 14, 2020

Conversation

tanhauhau
Copy link
Member

Fixes #4993
Fixes #5118

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases, features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests with npm test or yarn test)

@tanhauhau tanhauhau force-pushed the tanhauhau/gh-4993 branch from 52863a6 to a65088c Compare July 10, 2020 09:35
@Conduitry
Copy link
Member

@tanhauhau What do you think about only including this extra check if the component uses $$props or $$restProps? In the js sample updates, I see a lot of cases where we're adding extra code for nothing. There's no reason to check is_empty($$props) if right after that we're checking 'foo' in $$props.

@tanhauhau
Copy link
Member Author

I was thinking whether the early return can skip the rest of props dirty checking, but I guess less code is worth the trade off?

@Conduitry
Copy link
Member

Yeah, I'm not sure. In cases where we just have the one prop being checked for, the extra is_empty check obviously only slows us down. This probably comes up more in tests than it comes up in real life components. I don't think we want to get into something like including the is_empty check if we have more than some number of in $$props checks later in the function.

In what sorts of situations might $set be called with {}? How often does that happen?

@tanhauhau
Copy link
Member Author

In what sorts of situations might $set be called with {}? How often does that happen?

when a InlineComponent has dynamic attribute, it will always call the $set in the p function, even though there may be no changes.

@tanhauhau tanhauhau force-pushed the tanhauhau/gh-4993 branch from 152516e to 4756954 Compare July 14, 2020 03:15
@Conduitry Conduitry merged commit d472bd2 into sveltejs:master Jul 14, 2020
@tanhauhau tanhauhau deleted the tanhauhau/gh-4993 branch July 15, 2020 08:40
hontas added a commit to hontas/svelte that referenced this pull request Jul 18, 2020
* upstream/master: (190 commits)
  invalidate $$props and $$restProps only when there are changes (sveltejs#5123)
  site: use https in link in blog (sveltejs#5148)
  Simplify each block bindings example (sveltejs#5094)
  fix $$props reactive for slots (sveltejs#5125)
  site: add FAQ entry for how to document a svelte component (sveltejs#5131)
  site: remove an obsolete TODO in blog post (sveltejs#5135)
  Increase timeout for unit build
  Increase timeout for unit tests
  -> v3.24.0
  spread condition for input element (sveltejs#5004)
  update changelog
  fix(5018): compare wholeText instead of data (sveltejs#5028)
  html anchor in head (sveltejs#5071)
  error on expression scope store (sveltejs#5079)
  update changelog
  preprocess self-closing script and style tags (sveltejs#5082)
  update changelog
  fix: Parameters with default values are optional (sveltejs#5083)
  make builds time out after a reasonable period (sveltejs#5100)
  site: fix blog typo (sveltejs#5090)
  ...
hontas added a commit to hontas/svelte that referenced this pull request Jul 18, 2020
* master: (67 commits)
  add updating guard to binding callback (sveltejs#5126)
  Bump lodash from 4.17.15 to 4.17.19 (sveltejs#5152)
  Bump lodash from 4.17.15 to 4.17.19 in /site (sveltejs#5155)
  Fixes sveltejs#5153 (sveltejs#5154)
  invalidate $$props and $$restProps only when there are changes (sveltejs#5123)
  site: use https in link in blog (sveltejs#5148)
  Simplify each block bindings example (sveltejs#5094)
  fix $$props reactive for slots (sveltejs#5125)
  site: add FAQ entry for how to document a svelte component (sveltejs#5131)
  site: remove an obsolete TODO in blog post (sveltejs#5135)
  Increase timeout for unit build
  Increase timeout for unit tests
  -> v3.24.0
  spread condition for input element (sveltejs#5004)
  update changelog
  fix(5018): compare wholeText instead of data (sveltejs#5028)
  html anchor in head (sveltejs#5071)
  error on expression scope store (sveltejs#5079)
  update changelog
  preprocess self-closing script and style tags (sveltejs#5082)
  ...
Truffula pushed a commit to Truffula/svelte that referenced this pull request Aug 3, 2020
taylorzane pushed a commit to taylorzane/svelte that referenced this pull request Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants