|
|
|
@ -1,10 +1,19 @@
|
|
|
|
|
|
|
|
import { DEV } from 'esm-env';
|
|
|
|
import { queue_micro_task } from './task.js';
|
|
|
|
import { queue_micro_task } from './task.js';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var seen = new Set();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {Node} anchor
|
|
|
|
* @param {Node} anchor
|
|
|
|
* @param {{ hash: string, code: string }} css
|
|
|
|
* @param {{ hash: string, code: string }} css
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function append_styles(anchor, css) {
|
|
|
|
export function append_styles(anchor, css) {
|
|
|
|
|
|
|
|
// in dev, always check the DOM, so that styles can be replaced with HMR
|
|
|
|
|
|
|
|
if (!DEV) {
|
|
|
|
|
|
|
|
if (seen.has(css)) return;
|
|
|
|
|
|
|
|
seen.add(css);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Use `queue_micro_task` to ensure `anchor` is in the DOM, otherwise getRootNode() will yield wrong results
|
|
|
|
// Use `queue_micro_task` to ensure `anchor` is in the DOM, otherwise getRootNode() will yield wrong results
|
|
|
|
queue_micro_task(() => {
|
|
|
|
queue_micro_task(() => {
|
|
|
|
var root = anchor.getRootNode();
|
|
|
|
var root = anchor.getRootNode();
|
|
|
|
|