-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
fix(runtime-core): handle nested reactive object in guardReactiveProps #11693
Open
linzhe141
wants to merge
8
commits into
vuejs:main
Choose a base branch
from
linzhe141:fix-guardReactiveProps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5f988c2
fix: fix guardReactiveProps in v-bind case
linzhe141 ad3a8bf
chore: update test
linzhe141 48ccf40
chore: update
linzhe141 4de3bbf
Merge branch 'main' into fix-guardReactiveProps
linzhe141 6185f95
chore: updae test
linzhe141 7b25a6f
Merge branch 'fix-guardReactiveProps' of https://github.com/linzhe141…
linzhe141 d71753d
chore: update
linzhe141 e320f30
chore: update
linzhe141 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
import { patchProp } from '../src/patchProp' | ||
import { h, nextTick, ref, render } from '../src' | ||
import { | ||
createElementBlock, | ||
guardReactiveProps, | ||
h, | ||
nextTick, | ||
normalizeProps, | ||
reactive, | ||
ref, | ||
render, | ||
toRefs, | ||
} from '../src' | ||
|
||
describe('runtime-dom: props patching', () => { | ||
test('basic', () => { | ||
|
@@ -351,4 +361,38 @@ describe('runtime-dom: props patching', () => { | |
expect(el.translate).toBeFalsy() | ||
expect(el.getAttribute('translate')).toBe('no') | ||
}) | ||
|
||
// #11691 | ||
test('should update the color style of the element from red to yellow after a timeout', async () => { | ||
const state = reactive({ | ||
obj: { | ||
style: { | ||
color: 'red', | ||
}, | ||
}, | ||
}) | ||
const App = { | ||
setup() { | ||
const { obj } = toRefs(state) | ||
setTimeout(async () => { | ||
state.obj.style.color = 'yellow' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not move those 3 lines to the end of this case? |
||
await nextTick() | ||
expect(el.style.color).toBe('yellow') | ||
}) | ||
return () => { | ||
// <div v-bind="obj">msg</div> | ||
return createElementBlock( | ||
'div', | ||
normalizeProps(guardReactiveProps(obj.value)), | ||
'msg', | ||
17, | ||
) | ||
} | ||
}, | ||
} | ||
const root = document.createElement('div') | ||
render(h(App), root) | ||
const el = root.children[0] as HTMLSelectElement | ||
expect(el.style.color).toBe('red') | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check
props[key]
is Object first.consider the following situation:
In theory, only 2 layers of nesting need to be handled here, and for safety, maybe it is necessary to deal with deep recursive processing.