@skyux/core 13.0.0 → 13.1.0
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/fesm2022/skyux-core.mjs +29 -22
- package/fesm2022/skyux-core.mjs.map +1 -1
- package/package.json +2 -2
package/fesm2022/skyux-core.mjs
CHANGED
|
@@ -4134,31 +4134,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
|
|
|
4134
4134
|
* Trims whitespace in each text node that is a direct descendent of the current element.
|
|
4135
4135
|
*/
|
|
4136
4136
|
class SkyTrimDirective {
|
|
4137
|
-
#
|
|
4137
|
+
#el;
|
|
4138
4138
|
#obs;
|
|
4139
4139
|
constructor(elRef, mutationObs) {
|
|
4140
|
-
this.#
|
|
4140
|
+
this.#el = elRef.nativeElement;
|
|
4141
4141
|
this.#obs = mutationObs.create((mutations) => {
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
if (mutation.target.parentNode === elRef.nativeElement) {
|
|
4146
|
-
nodes.push(mutation.target);
|
|
4147
|
-
}
|
|
4142
|
+
if (mutations.some((mutation) => mutation.target === this.#el.firstChild ||
|
|
4143
|
+
mutation.target === this.#el.lastChild)) {
|
|
4144
|
+
this.#trimNodes();
|
|
4148
4145
|
}
|
|
4149
|
-
this.#trim(nodes);
|
|
4150
4146
|
});
|
|
4151
4147
|
this.#observe();
|
|
4152
4148
|
}
|
|
4153
4149
|
ngOnInit() {
|
|
4154
|
-
|
|
4155
|
-
this.#trim(Array.from(el.childNodes));
|
|
4150
|
+
this.#trimNodes();
|
|
4156
4151
|
}
|
|
4157
4152
|
ngOnDestroy() {
|
|
4158
4153
|
this.#disconnect();
|
|
4159
4154
|
}
|
|
4160
4155
|
#observe() {
|
|
4161
|
-
this.#obs.observe(this.#
|
|
4156
|
+
this.#obs.observe(this.#el, {
|
|
4162
4157
|
characterData: true,
|
|
4163
4158
|
subtree: true,
|
|
4164
4159
|
});
|
|
@@ -4166,20 +4161,32 @@ class SkyTrimDirective {
|
|
|
4166
4161
|
#disconnect() {
|
|
4167
4162
|
this.#obs.disconnect();
|
|
4168
4163
|
}
|
|
4169
|
-
#
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4164
|
+
#trimNodes() {
|
|
4165
|
+
const el = this.#el;
|
|
4166
|
+
if (el.hasChildNodes()) {
|
|
4167
|
+
// Suspend the MutationObserver so altering the text content of each node
|
|
4168
|
+
// doesn't retrigger the observe callback.
|
|
4169
|
+
this.#disconnect();
|
|
4170
|
+
if (el.firstChild === el.lastChild) {
|
|
4171
|
+
this.#trimNode(el.firstChild, 'trim');
|
|
4172
|
+
}
|
|
4173
|
+
else {
|
|
4174
|
+
this.#trimNode(el.firstChild, 'trimStart');
|
|
4175
|
+
this.#trimNode(el.lastChild, 'trimEnd');
|
|
4176
|
+
}
|
|
4177
|
+
this.#observe();
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
#trimNode(node, trimMethod) {
|
|
4181
|
+
if (node?.nodeType === Node.TEXT_NODE) {
|
|
4182
|
+
const textContent = node.textContent;
|
|
4183
|
+
if (textContent) {
|
|
4184
|
+
const textContentTrimmed = textContent[trimMethod]();
|
|
4177
4185
|
if (textContent !== textContentTrimmed) {
|
|
4178
4186
|
node.textContent = textContentTrimmed;
|
|
4179
4187
|
}
|
|
4180
4188
|
}
|
|
4181
4189
|
}
|
|
4182
|
-
this.#observe();
|
|
4183
4190
|
}
|
|
4184
4191
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: SkyTrimDirective, deps: [{ token: i0.ElementRef }, { token: SkyMutationObserverService }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
4185
4192
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: SkyTrimDirective, isStandalone: false, selector: "[skyTrim]", ngImport: i0 }); }
|
|
@@ -4738,7 +4745,7 @@ class Version {
|
|
|
4738
4745
|
/**
|
|
4739
4746
|
* Represents the version of @skyux/core.
|
|
4740
4747
|
*/
|
|
4741
|
-
const VERSION = new Version('13.
|
|
4748
|
+
const VERSION = new Version('13.1.0');
|
|
4742
4749
|
|
|
4743
4750
|
/**
|
|
4744
4751
|
* Generated bundle index. Do not edit.
|