Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runDisconnectedCallback(vm: VM) {
if (process.env.NODE_ENV !== 'production') {
assert.isTrue(vm.state !== VMState.disconnected, `${vm} must be inserted.`);
}
if (isFalse(vm.isDirty)) {
// this guarantees that if the component is reused/reinserted,
// it will be re-rendered because we are disconnecting the reactivity
// linking, so mutations are not automatically reflected on the state
// of disconnected components.
vm.isDirty = true;
}
vm.state = VMState.disconnected;
// reporting disconnection
const { disconnected } = Services;
if (disconnected) {
invokeServiceHook(vm, disconnected);
}
const { disconnectedCallback } = vm.def;
if (!isUndefined(disconnectedCallback)) {
if (process.env.NODE_ENV !== 'production') {
startMeasure('disconnectedCallback', vm);
);
assert.isFalse(
isBeingConstructed(vm),
`Failed to construct '${getComponentTag(
vm
)}': The result must not have attributes.`
);
assert.invariant(
!isObject(newValue) || isNull(newValue),
`Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`
);
}
if (newValue !== vm.cmpProps[propName]) {
vm.cmpProps[propName] = newValue;
if (isFalse(vm.isDirty)) {
// perf optimization to skip this step if not in the DOM
valueMutated(this, propName);
}
}
return set.call(vm.elm, newValue);
},
};
for (let i = 0, len = children.length; i < len; i += 1) {
const vnode = children[i];
if (isNull(vnode)) {
continue;
}
const { data } = vnode;
const slotName = ((data.attrs && data.attrs.slot) || '') as string;
const vnodes: VNodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
// re-keying the vnodes is necessary to avoid conflicts with default content for the slot
// which might have similar keys. Each vnode will always have a key that
// starts with a numeric character from compiler. In this case, we add a unique
// notation for slotted vnodes keys, e.g.: `@foo:1:1`
vnode.key = `@${slotName}:${vnode.key}`;
ArrayPush.call(vnodes, vnode);
}
if (isFalse(vm.isDirty)) {
// We need to determine if the old allocation is really different from the new one
// and mark the vm as dirty
const oldKeys = keys(oldSlots);
if (oldKeys.length !== keys(cmpSlots).length) {
markComponentAsDirty(vm);
return;
}
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
const key = oldKeys[i];
if (isUndefined(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
markComponentAsDirty(vm);
return;
}
const oldVNodes = oldSlots[key];
const vnodes = cmpSlots[key];
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
!isInvokingRender,
`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString(
key
)}`
);
assert.invariant(
!isUpdatingTemplate,
`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString(
key
)}`
);
}
const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
if (reactiveOrAnyValue !== vm.cmpTrack[key]) {
vm.cmpTrack[key] = reactiveOrAnyValue;
if (isFalse(vm.isDirty)) {
// perf optimization to skip this step if the track property is on a component that is already dirty
valueMutated(this, key);
}
}
},
enumerable,
set(this: ComponentInterface, newValue: any) {
const vm = getAssociatedVM(this);
if (newValue !== vm.cmpTrack[key]) {
vm.cmpTrack[key] = newValue;
if (isFalse(vm.isDirty)) {
valueMutated(this, key);
}
}
},
enumerable: true,
value(this: Node, newChild: Node, oldChild: Node) {
if (this instanceof Element && isFalse(options.isPortal)) {
logError(portalRestrictionErrorMessage('replaceChild', 'method'));
}
return replaceChild.call(this, newChild, oldChild);
},
}),