How to use the @vue/reactivity.unlock function in @vue/reactivity

To help you get started, we’ve selected a few @vue/reactivity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-next / packages / runtime-core / src / componentProps.ts View on Github external
let attrs: Data | undefined = void 0

  // update the instance propsProxy (passed to setup()) to trigger potential
  // changes
  const propsProxy = instance.propsProxy
  const setProp = propsProxy
    ? (key: string, val: unknown) => {
        props[key] = val
        propsProxy[key] = val
      }
    : (key: string, val: unknown) => {
        props[key] = val
      }

  // allow mutation of propsProxy (which is readonly by default)
  unlock()

  if (rawProps != null) {
    for (const key in rawProps) {
      // key, ref are reserved and never passed down
      if (key === 'key' || key === 'ref') continue
      // prop option names are camelized during normalization, so to support
      // kebab -> camel conversion here we need to camelize the key.
      const camelKey = camelize(key)
      if (hasDeclaredProps && !hasOwn(options, camelKey)) {
        // Any non-declared props are put into a separate `attrs` object
        // for spreading. Make sure to preserve original key casing
        ;(attrs || (attrs = {}))[key] = rawProps[key]
      } else {
        setProp(camelKey, rawProps[key])
      }
    }