Skip to content

Commit 44899b3

Browse files
committed
fix(clone): ensure placeholder color is correctly rendered in SVG
1 parent 73358a1 commit 44899b3

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ drafts/
141141

142142
demos/
143143

144-
__tests__/__screenshots__
145144
__snapshots__
146145

147146
.vscode/

src/core/clone.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ export async function deepClone(node, sessionCache, options) {
344344
}
345345
}
346346
}
347-
// #315: Preserve ::placeholder color for inputs/textareas showing placeholder text
347+
348+
// #315: Preserve placeholder for inputs/textareas showing placeholder text
348349
if ((node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) && !node.value && node.placeholder) {
349350
try {
350351
const phStyle = window.getComputedStyle(node, '::placeholder')
@@ -353,11 +354,12 @@ export async function deepClone(node, sessionCache, options) {
353354
const uid = 'snapdom-ph-' + (Math.random() * 1e6 | 0)
354355
clone.classList.add(uid)
355356
const styleEl = document.createElement('style')
356-
styleEl.textContent = `.${uid}::placeholder{color:${phColor}!important;opacity:${phStyle.opacity || '1'}!important;}`
357+
styleEl.textContent = `.${uid}::placeholder{color:${phColor}!important;opacity:${phStyle.opacity || '1'}!important;-webkit-text-fill-color:${phColor}!important;}`
357358
clone.prepend(styleEl)
358359
}
359360
} catch { /* non-blocking */ }
360361
}
362+
361363
if (node instanceof HTMLSelectElement) {
362364
pendingSelectValue = node.value
363365
}
@@ -490,7 +492,6 @@ export async function deepClone(node, sessionCache, options) {
490492
}
491493
if (pendingTextAreaValue !== null && clone instanceof HTMLTextAreaElement) {
492494
clone.textContent = pendingTextAreaValue
493-
494495
}
495496
return clone
496497
}

0 commit comments

Comments
 (0)