1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var xlinkNS = 'http://www.w3.org/1999/xlink';
|
4 | var xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
5 | var colonChar = 58;
|
6 | var xChar = 120;
|
7 | function updateAttrs(oldVnode, vnode) {
|
8 | var key, elm = vnode.elm, oldAttrs = oldVnode.data.attrs, attrs = vnode.data.attrs;
|
9 | if (!oldAttrs && !attrs)
|
10 | return;
|
11 | if (oldAttrs === attrs)
|
12 | return;
|
13 | oldAttrs = oldAttrs || {};
|
14 | attrs = attrs || {};
|
15 |
|
16 | for (key in attrs) {
|
17 | var cur = attrs[key];
|
18 | var old = oldAttrs[key];
|
19 | if (old !== cur) {
|
20 | if (cur === true) {
|
21 | elm.setAttribute(key, "");
|
22 | }
|
23 | else if (cur === false) {
|
24 | elm.removeAttribute(key);
|
25 | }
|
26 | else {
|
27 | if (key.charCodeAt(0) !== xChar) {
|
28 | elm.setAttribute(key, cur);
|
29 | }
|
30 | else if (key.charCodeAt(3) === colonChar) {
|
31 |
|
32 | elm.setAttributeNS(xmlNS, key, cur);
|
33 | }
|
34 | else if (key.charCodeAt(5) === colonChar) {
|
35 |
|
36 | elm.setAttributeNS(xlinkNS, key, cur);
|
37 | }
|
38 | else {
|
39 | elm.setAttribute(key, cur);
|
40 | }
|
41 | }
|
42 | }
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 | for (key in oldAttrs) {
|
48 | if (!(key in attrs)) {
|
49 | elm.removeAttribute(key);
|
50 | }
|
51 | }
|
52 | }
|
53 | exports.attributesModule = { create: updateAttrs, update: updateAttrs };
|
54 | exports.default = exports.attributesModule;
|
55 |
|
\ | No newline at end of file |