@d3plus/dom 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/es/src/date.js +16 -6
- package/package.json +1 -1
- package/umd/d3plus-dom.full.js +14 -4
- package/umd/d3plus-dom.full.js.map +1 -1
- package/umd/d3plus-dom.full.min.js +23 -23
- package/umd/d3plus-dom.js +14 -4
- package/umd/d3plus-dom.js.map +1 -1
- package/umd/d3plus-dom.min.js +3 -3
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ import modules from "@d3plus/dom";
|
|
|
13
13
|
In vanilla JavaScript, a `d3plus` global is exported from the pre-bundled version:
|
|
14
14
|
|
|
15
15
|
```html
|
|
16
|
-
<script src="https://cdn.jsdelivr.net/npm/@d3plus/dom
|
|
16
|
+
<script src="https://cdn.jsdelivr.net/npm/@d3plus/dom"></script>
|
|
17
17
|
<script>
|
|
18
18
|
console.log(d3plus);
|
|
19
19
|
</script>
|
package/es/src/date.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
date1.setFullYear(year1);
|
|
31
31
|
return date1;
|
|
32
32
|
}
|
|
33
|
-
// tests for quarterly formats (ie. "QX YYYY")
|
|
33
|
+
// tests for quarterly formats (ie. "QX YYYY" and "YYYY QX")
|
|
34
34
|
var quarterPrefix = new RegExp(/^([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})[\s|-]{0,1}(-*\d{1,4})$/g).exec(s);
|
|
35
35
|
var quarterSuffix = new RegExp(/^(-*\d{1,4})[\s|-]{0,1}([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})$/g).exec(s);
|
|
36
36
|
if (quarterPrefix || quarterSuffix) {
|
|
@@ -40,12 +40,22 @@
|
|
|
40
40
|
date2.setFullYear(year2);
|
|
41
41
|
return date2;
|
|
42
42
|
}
|
|
43
|
+
// tests for monthly formats (ie. "MM-YYYY" and "YYYY-MM")
|
|
44
|
+
var monthPrefix = new RegExp(/^([-*\d]{1,2})\-(-*\d{1,4})$/g).exec(s);
|
|
45
|
+
var monthSuffix = new RegExp(/^(-*\d{1,4})\-([-*\d]{1,2})$/g).exec(s);
|
|
46
|
+
if (monthPrefix || monthSuffix) {
|
|
47
|
+
var month = +(monthPrefix ? monthPrefix[1] : monthSuffix[2]);
|
|
48
|
+
var year3 = +(monthPrefix ? monthPrefix[2] : monthSuffix[1]);
|
|
49
|
+
var date3 = new Date(year3, month - 1, 1);
|
|
50
|
+
date3.setFullYear(year3);
|
|
51
|
+
return date3;
|
|
52
|
+
}
|
|
43
53
|
// detects if only passing a year value
|
|
44
54
|
if (!s.includes("/") && !s.includes(" ") && (!s.includes("-") || !s.indexOf("-"))) {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
return
|
|
55
|
+
var date4 = new Date(+s, 0, 1);
|
|
56
|
+
date4.setFullYear(d);
|
|
57
|
+
return date4;
|
|
48
58
|
}
|
|
49
|
-
// falls back to Date object
|
|
50
|
-
return new Date(s);
|
|
59
|
+
// falls back to Date object, replacing hyphens with slashes
|
|
60
|
+
return new Date(s.replace(/-/g, "/"));
|
|
51
61
|
}
|
package/package.json
CHANGED
package/umd/d3plus-dom.full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/dom v3.0.
|
|
2
|
+
@d3plus/dom v3.0.2
|
|
3
3
|
JavaScript functions for manipulating and analyzing DOM elements.
|
|
4
4
|
Copyright (c) 2025 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
date.setFullYear(year);
|
|
197
197
|
return date;
|
|
198
198
|
}
|
|
199
|
-
// tests for quarterly formats (ie. "QX YYYY")
|
|
199
|
+
// tests for quarterly formats (ie. "QX YYYY" and "YYYY QX")
|
|
200
200
|
const quarterPrefix = new RegExp(/^([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})[\s|-]{0,1}(-*\d{1,4})$/g).exec(s);
|
|
201
201
|
const quarterSuffix = new RegExp(/^(-*\d{1,4})[\s|-]{0,1}([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})$/g).exec(s);
|
|
202
202
|
if (quarterPrefix || quarterSuffix) {
|
|
@@ -206,14 +206,24 @@
|
|
|
206
206
|
date.setFullYear(year);
|
|
207
207
|
return date;
|
|
208
208
|
}
|
|
209
|
+
// tests for monthly formats (ie. "MM-YYYY" and "YYYY-MM")
|
|
210
|
+
const monthPrefix = new RegExp(/^([-*\d]{1,2})\-(-*\d{1,4})$/g).exec(s);
|
|
211
|
+
const monthSuffix = new RegExp(/^(-*\d{1,4})\-([-*\d]{1,2})$/g).exec(s);
|
|
212
|
+
if (monthPrefix || monthSuffix) {
|
|
213
|
+
const month = +(monthPrefix ? monthPrefix[1] : monthSuffix[2]);
|
|
214
|
+
const year = +(monthPrefix ? monthPrefix[2] : monthSuffix[1]);
|
|
215
|
+
const date = new Date(year, month - 1, 1);
|
|
216
|
+
date.setFullYear(year);
|
|
217
|
+
return date;
|
|
218
|
+
}
|
|
209
219
|
// detects if only passing a year value
|
|
210
220
|
if (!s.includes("/") && !s.includes(" ") && (!s.includes("-") || !s.indexOf("-"))) {
|
|
211
221
|
const date = new Date(+s, 0, 1);
|
|
212
222
|
date.setFullYear(d);
|
|
213
223
|
return date;
|
|
214
224
|
}
|
|
215
|
-
// falls back to Date object
|
|
216
|
-
return new Date(s);
|
|
225
|
+
// falls back to Date object, replacing hyphens with slashes
|
|
226
|
+
return new Date(s.replace(/-/g, "/"));
|
|
217
227
|
}
|
|
218
228
|
|
|
219
229
|
var xhtml = "http://www.w3.org/1999/xhtml";
|