-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_svg2.js
More file actions
24 lines (19 loc) · 791 Bytes
/
Copy pathtest_svg2.js
File metadata and controls
24 lines (19 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { createSVGWindow } from 'svgdom';
const window = createSVGWindow();
const document = window.document;
import { SVG, registerWindow } from '@svgdotjs/svg.js';
registerWindow(window, document);
const draw = SVG().addTo(document.documentElement)
// Simulate Nanquim's CSS rules
const style = document.createElement('style')
style.textContent = `
.newDrawing { stroke: white; }
`
document.documentElement.appendChild(style)
const text = draw.text("Test").addClass("newDrawing")
text.css('stroke', 'none')
// This is what Nanquim does:
const computedStyle = window.getComputedStyle(text.node)
console.log("computedStyle.stroke ===", computedStyle.stroke)
console.log("element.attr('stroke') ===", text.attr('stroke'))
console.log("element.css('stroke') ===", text.css('stroke'))