Skip to content

Commit

Permalink
Do not copy over crossorigin, integrity, referrerpolicy, or event han…
Browse files Browse the repository at this point in the history
…dlers
  • Loading branch information
jgerigmeyer committed Oct 15, 2024
1 parent 73e29c4 commit ce662ea
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/transform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { type StyleData } from './utils.js';

const excludeAttributes = [
'crossorigin',
'href',
'integrity',
'referrerpolicy',
];

export async function transformCSS(
styleData: StyleData[],
inlineStyles?: Map<HTMLElement, Record<string, string>>,
Expand All @@ -18,9 +25,11 @@ export async function transformCSS(
const url = URL.createObjectURL(blob);
const link = document.createElement('link');
for (const name of el.getAttributeNames()) {
const attr = el.getAttribute(name);
if (attr !== null && name !== 'href') {
link.setAttribute(name, attr);
if (!name.startsWith('on') && !excludeAttributes.includes(name)) {
const attr = el.getAttribute(name);
if (attr !== null) {
link.setAttribute(name, attr);
}
}
}
link.setAttribute('href', url);
Expand Down

0 comments on commit ce662ea

Please sign in to comment.