Skip to content

Conversation

lijingfaatcumt
Copy link

delete useless code in function reactive(#2951)
i think the code above i delete is useless, because in function createReactiveObject will solve the situation that if trying to observe a readonly proxy, return the readonly version, becasuse in createReactiveObject , except readonly() on a reactive object,
as long as the target is a proxy, the function createReactiveObject will return the target, so the code is repleat, and when i delete
the code above i mentioned, when i run 'npm test', it can pass and has no errors

@posva
Copy link
Member

posva commented Jan 7, 2021

If you are submitting a fix, can you add a test that failed before and now passes?

@posva posva changed the title fix(reactive): delete useless code in function reactive(closed#2951) fix(reactive): delete useless code in function reactive Jan 7, 2021
@lijingfaatcumt
Copy link
Author

lijingfaatcumt commented Jan 8, 2021

If you are submitting a fix, can you add a test that failed before and now passes

@posva i only find 4 line code that i think they are useless, and i want to delete them, and when i delete them and run 'npm test', there are no errors, so i pull this request, then reason i think useless is bellow

if (
    target[ReactiveFlags.RAW] &&
    !(isReadonly && target[ReactiveFlags.IS_REACTIVE])
  ) {
    return target
  }

in function createReactiveObject can return the proxy if the target is a readonly proxy, so

//if trying to observe a readonly proxy, return the readonly version.
  if (target && (target as Target)[ReactiveFlags.IS_READONLY]) {
    return target
  }

in function reactive can deleted

@lijingfaatcumt
Copy link
Author

lijingfaatcumt commented Jan 8, 2021

If you are submitting a fix, can you add a test that failed before and now passes?

no, originally i want to mention a bug, but this is not a bug,so the bug i mentioned is closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants