@lynx-js/web-elements 0.12.10 → 0.12.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lynx-js/web-elements
2
2
 
3
+ ## 0.12.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Defer `x-image` and `inline-image` load events received while detached until the host connects to the document, preserving the image dimensions at load time. ([#3906](https://github.com/lynx-family/lynx-stack/pull/3906))
8
+
9
+ - Apply inline image layout styles to `x-svg` inside text and custom truncation content. ([#3899](https://github.com/lynx-family/lynx-stack/pull/3899))
10
+
3
11
  ## 0.12.10
4
12
 
5
13
  ### Patch Changes
@@ -4,5 +4,6 @@ export declare class ImageEvents implements InstanceType<AttributeReactiveClass<
4
4
  static observedAttributes: never[];
5
5
  _enableLoadEvent(status: boolean): void;
6
6
  _enableErrorEvent(status: boolean): void;
7
+ connectedCallback(): void;
7
8
  constructor(dom: HTMLElement);
8
9
  }
@@ -22,6 +22,7 @@ let ImageEvents = (() => {
22
22
  }
23
23
  static observedAttributes = [];
24
24
  #dom = __runInitializers(this, _instanceExtraInitializers);
25
+ #pendingLoadEvents = [];
25
26
  #getImg = genDomGetter(() => this.#dom.shadowRoot, '#img');
26
27
  _enableLoadEvent(status) {
27
28
  if (status) {
@@ -31,6 +32,7 @@ let ImageEvents = (() => {
31
32
  }
32
33
  else {
33
34
  this.#getImg().removeEventListener('load', this.#teleportLoadEvent);
35
+ this.#pendingLoadEvents = [];
34
36
  }
35
37
  }
36
38
  _enableErrorEvent(status) {
@@ -44,14 +46,26 @@ let ImageEvents = (() => {
44
46
  }
45
47
  }
46
48
  #teleportLoadEvent = () => {
47
- this.#dom.dispatchEvent(new CustomEvent('load', {
49
+ const event = new CustomEvent('load', {
48
50
  ...commonComponentEventSetting,
49
51
  detail: {
50
52
  width: this.#getImg().naturalWidth,
51
53
  height: this.#getImg().naturalHeight,
52
54
  },
53
- }));
55
+ });
56
+ if (this.#dom.isConnected) {
57
+ this.#dom.dispatchEvent(event);
58
+ }
59
+ else {
60
+ // Preserve the dimensions at load time until the host joins the document.
61
+ this.#pendingLoadEvents.push(event);
62
+ }
54
63
  };
64
+ connectedCallback() {
65
+ while (this.#dom.isConnected && this.#pendingLoadEvents.length) {
66
+ this.#dom.dispatchEvent(this.#pendingLoadEvents.shift());
67
+ }
68
+ }
55
69
  #teleportErrorEvent = () => {
56
70
  this.#dom.dispatchEvent(new CustomEvent('error', {
57
71
  ...commonComponentEventSetting,
@@ -6,6 +6,7 @@ import { __esDecorate, __runInitializers } from "tslib";
6
6
  */
7
7
  import { Component, genDomGetter, registerAttributeHandler, } from '../../element-reactive/index.js';
8
8
  import { templateInlineImage } from '../htmlTemplates.js';
9
+ import { ImageEvents } from '../XImage/ImageEvents.js';
9
10
  let InlineImageAttributes = (() => {
10
11
  let _instanceExtraInitializers = [];
11
12
  let __handleSrc_decorators;
@@ -35,7 +36,7 @@ export { InlineImageAttributes };
35
36
  * @deprecated you can use `x-image` instead in `x-text`.
36
37
  */
37
38
  let InlineImage = (() => {
38
- let _classDecorators = [Component('inline-image', [InlineImageAttributes], templateInlineImage({}))];
39
+ let _classDecorators = [Component('inline-image', [InlineImageAttributes, ImageEvents], templateInlineImage({}))];
39
40
  let _classDescriptor;
40
41
  let _classExtraInitializers = [];
41
42
  let _classThis;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-elements",
3
- "version": "0.12.10",
3
+ "version": "0.12.11",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -143,14 +143,14 @@
143
143
  "markdown-it": "^15.0.1"
144
144
  },
145
145
  "devDependencies": {
146
+ "@lynx-js/playwright-fixtures": "0.0.0",
146
147
  "@playwright/test": "^1.61.1",
147
- "@rsbuild/core": "2.2.3",
148
+ "@rsbuild/core": "2.2.4",
148
149
  "@rsbuild/plugin-source-build": "1.0.6",
149
150
  "@types/markdown-it": "^14.1.2",
150
151
  "@types/node": "^24.13.3",
151
152
  "nyc": "^18.0.0",
152
- "tslib": "^2.8.1",
153
- "@lynx-js/playwright-fixtures": "0.0.0"
153
+ "tslib": "^2.8.1"
154
154
  },
155
155
  "peerDependencies": {
156
156
  "tslib": "^2.5.0"
@@ -68,16 +68,22 @@ inline-truncation > lynx-wrapper > x-text {
68
68
 
69
69
  x-text > inline-image,
70
70
  x-text > x-image,
71
+ x-text > x-svg,
71
72
  inline-truncation > inline-image,
72
73
  inline-truncation > x-image,
74
+ inline-truncation > x-svg,
73
75
  inline-text > inline-image,
74
76
  inline-text > x-image,
77
+ inline-text > x-svg,
75
78
  x-text > lynx-wrapper > inline-image,
76
79
  x-text > lynx-wrapper > x-image,
80
+ x-text > lynx-wrapper > x-svg,
77
81
  inline-truncation > lynx-wrapper > inline-image,
78
82
  inline-truncation > lynx-wrapper > x-image,
83
+ inline-truncation > lynx-wrapper > x-svg,
79
84
  inline-text > lynx-wrapper > inline-image,
80
- inline-text > lynx-wrapper > x-image {
85
+ inline-text > lynx-wrapper > x-image,
86
+ inline-text > lynx-wrapper > x-svg {
81
87
  display: contents !important;
82
88
  }
83
89
 
@@ -118,9 +124,13 @@ inline-image::part(img) {
118
124
  }
119
125
 
120
126
  x-text > x-image::part(img),
127
+ x-text > x-svg::part(img),
121
128
  x-text > lynx-wrapper > x-image::part(img),
129
+ x-text > lynx-wrapper > x-svg::part(img),
122
130
  inline-truncation > x-image::part(img),
123
- inline-truncation > lynx-wrapper > x-image::part(img) {
131
+ inline-truncation > x-svg::part(img),
132
+ inline-truncation > lynx-wrapper > x-image::part(img),
133
+ inline-truncation > lynx-wrapper > x-svg::part(img) {
124
134
  display: inline-block;
125
135
  height: inherit !important;
126
136
  width: inherit !important;
@@ -159,11 +169,13 @@ x-text[text-selection] > inline-text,
159
169
  x-text[text-selection] > x-text,
160
170
  x-text[text-selection] > inline-image,
161
171
  x-text[text-selection] > x-image,
172
+ x-text[text-selection] > x-svg,
162
173
  x-text[text-selection] > inline-truncation,
163
174
  x-text[text-selection] > lynx-wrapper > inline-text,
164
175
  x-text[text-selection] > lynx-wrapper > x-text,
165
176
  x-text[text-selection] > lynx-wrapper > inline-image,
166
177
  x-text[text-selection] > lynx-wrapper > x-image,
178
+ x-text[text-selection] > lynx-wrapper > x-svg,
167
179
  x-text[text-selection] > lynx-wrapper > inline-truncation {
168
180
  -webkit-user-select: auto;
169
181
  user-select: auto;