Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected getExtraAttrs(domNode: Node) {
if (this.type === ExtensionType.Plain) {
throw new Error('Invalid use of extraAttrs within a plain extension.');
}
const extraAttrs = (this.options.extraAttrs as ExtraAttrs[] | undefined) ?? [];
const attrs: Attrs = Object.create(null);
for (const item of extraAttrs) {
if (Array.isArray(item)) {
// Use the default
const [name, , attributeName] = item;
attrs[name] = attributeName ? (domNode as Element).getAttribute(attributeName) : undefined;
} else if (isString(item)) {
// Assume the name is the same
attrs[item] = (domNode as Element).getAttribute(item);
} else {
const { name, getAttrs, default: fallback } = item;
export const isPlainExtension = (extension: unknown): extension is Extension =>
isExtension(extension) && extension.type === ExtensionType.Plain;