in packages/miniapp-runtime/src/dom/element.ts [221:286]
public removeAttribute(qualifiedName: string) {
const isStaticView = this.nodeName === VIEW && isHasExtractProp(this) && !this.isAnyEventBinded();
MutationObserver.record({
target: this,
type: MutationRecordType.ATTRIBUTES,
attributeName: qualifiedName,
oldValue: this.getAttribute(qualifiedName),
});
if (qualifiedName === STYLE) {
this.style.cssText = '';
} else {
const isInterrupt = hooks.call('onRemoveAttribute', this, qualifiedName);
if (isInterrupt) {
return;
}
if (!Object.prototype.hasOwnProperty.call(this.props, qualifiedName)) {
return;
}
delete this.props[qualifiedName];
}
// Serialization
if (!this._root) return;
const componentsAlias = getComponentsAlias();
const _alias = componentsAlias[this.nodeName];
const viewAlias = componentsAlias[VIEW]._num;
const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
const pureViewAlias = componentsAlias[PURE_VIEW]._num;
const { _path } = this;
qualifiedName = shortcutAttr(qualifiedName);
const payload = {
path: `${_path}.${toCamelCase(qualifiedName)}`,
value: '',
};
hooks.call('modifyRmAttrPayload', this, qualifiedName, payload, componentsAlias);
if (_alias) {
const qualifiedNameAlias = _alias[qualifiedName] || qualifiedName;
payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`;
}
this.enqueueUpdate(payload);
if (this.nodeName === VIEW) {
if (toCamelCase(qualifiedName) === CATCHMOVE) {
// catch-view => view or static-view or pure-view
this.enqueueUpdate({
path: `${_path}.${Shortcuts.NodeName}`,
value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias),
});
} else if (isStaticView && !isHasExtractProp(this)) {
// static-view => pure-view
this.enqueueUpdate({
path: `${_path}.${Shortcuts.NodeName}`,
value: pureViewAlias,
});
}
}
}