36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| import { e as l, i as u, t as c, T as d } from "./class-map-CwiboTfb.mjs";
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2018 Google LLC
 | |
|  * SPDX-License-Identifier: BSD-3-Clause
 | |
|  */
 | |
| const o = "important", a = " !" + o, h = l(class extends u {
 | |
|   constructor(n) {
 | |
|     var e;
 | |
|     if (super(n), n.type !== c.ATTRIBUTE || n.name !== "style" || ((e = n.strings) == null ? void 0 : e.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
 | |
|   }
 | |
|   render(n) {
 | |
|     return Object.keys(n).reduce((e, s) => {
 | |
|       const t = n[s];
 | |
|       return t == null ? e : e + `${s = s.includes("-") ? s : s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${t};`;
 | |
|     }, "");
 | |
|   }
 | |
|   update(n, [e]) {
 | |
|     const { style: s } = n.element;
 | |
|     if (this.ft === void 0) return this.ft = new Set(Object.keys(e)), this.render(e);
 | |
|     for (const t of this.ft) e[t] == null && (this.ft.delete(t), t.includes("-") ? s.removeProperty(t) : s[t] = null);
 | |
|     for (const t in e) {
 | |
|       const r = e[t];
 | |
|       if (r != null) {
 | |
|         this.ft.add(t);
 | |
|         const i = typeof r == "string" && r.endsWith(a);
 | |
|         t.includes("-") || i ? s.setProperty(t, i ? r.slice(0, -11) : r, i ? o : "") : s[t] = r;
 | |
|       }
 | |
|     }
 | |
|     return d;
 | |
|   }
 | |
| });
 | |
| export {
 | |
|   h as o
 | |
| };
 |