Skip to content

Commit

Permalink
fix: abnormal attribute regex (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed Aug 25, 2023
1 parent 0973c6c commit 9a9b2eb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/clone-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function applyCssStyleWithOptions(
if (styles) for (const name in styles) clonedStyle[name] = styles[name]!
}

const ABNORMAL_ATTRIBUTE_RE = /^[\w-]+$/
/** @example "'{ */
const NORMAL_ATTRIBUTE_RE = /^[\w-:]+$/

export async function cloneNode<T extends Node>(
node: T,
Expand All @@ -93,7 +94,7 @@ export async function cloneNode<T extends Node>(
const names = cloned.getAttributeNames()
for (let len = names.length, i = 0; i < len; i++) {
const name = names[i]
if (!ABNORMAL_ATTRIBUTE_RE.test(name)) {
if (!NORMAL_ATTRIBUTE_RE.test(name)) {
cloned.removeAttribute(name)
}
}
Expand Down

1 comment on commit 9a9b2eb

@vercel
Copy link

@vercel vercel bot commented on 9a9b2eb Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

modern-screenshot – ./

modern-screenshot-qq15725.vercel.app
modern-screenshot-git-main-qq15725.vercel.app
modern-screenshot.vercel.app

Please sign in to comment.