-
Notifications
You must be signed in to change notification settings - Fork 668
feat: throw error if the read-only property is tried to change #749
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,21 @@ import type VueWrapper from './vue-wrapper' | |
import { throwError, warn } from 'shared/util' | ||
|
||
export default class WrapperArray implements BaseWrapper { | ||
wrappers: Array<Wrapper | VueWrapper>; | ||
length: number; | ||
+wrappers: Array<Wrapper | VueWrapper>; | ||
+length: number; | ||
|
||
constructor (wrappers: Array<Wrapper | VueWrapper>) { | ||
this.wrappers = wrappers || [] | ||
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.
|
||
this.length = this.wrappers.length | ||
const length = wrappers.length | ||
// $FlowIgnore | ||
Object.defineProperty(this, 'wrappers', { | ||
get: () => wrappers, | ||
set: () => {} | ||
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. We should throw an error to tell the users it's read only. I realize this isn't part of this PR, but I think we should do the same for vnode, and element. 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. Thank you for pointing out. 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.
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. Thanks. No I don't think it needs to be documented 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. Thank you for reply. |
||
}) | ||
// $FlowIgnore | ||
Object.defineProperty(this, 'length', { | ||
get: () => length, | ||
set: () => {} | ||
}) | ||
} | ||
|
||
at (index: number): Wrapper | VueWrapper { | ||
|
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.
Cool I didn't know you could specify read only with flow 👍