@symbiotejs/symbiote 3.4.1 → 3.4.3

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/AI_REFERENCE.md CHANGED
@@ -153,7 +153,7 @@ Prefixes control which data context a binding resolves to:
153
153
  | Prefix | Meaning | Example | Description |
154
154
  |--------|---------|---------|-------------|
155
155
  | _(none)_ | Local state | `{{count}}` | Current component's local context |
156
- | `^` | Parent inherited | `{{^parentProp}}` | Walk up DOM ancestry to find nearest component that has this prop in its data context (`init$` / `add$()`) |
156
+ | `^` | Pop-up | `{{^parentProp}}` | Walk up DOM ancestry to find nearest component that has this prop in its data context (`init$` / `add$()`) |
157
157
  | `*` | Shared context | `{{*sharedProp}}` | Shared context scoped by `ctx` attribute or CSS `--ctx` |
158
158
  | `/` | Named context | `{{APP/myProp}}` | Global named context identified by key before `/` |
159
159
  | `--` | CSS Data | `{{--my-css-var}}` | Read value from CSS custom property |
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.4.3
4
+
5
+ ### Fixed
6
+
7
+ - **SSR: shared context props (`*prop`) with `ctx` attribute.** `getCssData()` attempted `window.getComputedStyle()` during server-side rendering, which is unavailable in linkedom. Now returns `null` immediately when `globalThis.__SYMBIOTE_SSR` is set, skipping all computed CSS reads on the server.
8
+
9
+ ### Added
10
+
11
+ - **DevMode warning for CSS data bindings in SSR/ISO mode.** When `devMode = true` and the component has `ssrMode` or `isoMode`, a `console.warn` fires for each `bindCssData` call — computed styles are unavailable during SSR, so the init value is used instead.
12
+
13
+ ## 3.4.2
14
+
15
+ ### Fixed
16
+
17
+ - **isoMode: Shadow DOM components with Light DOM slot children.** `isoMode` checked `this.childNodes` to detect SSR content, but for Shadow DOM components Light DOM children are slot content — not server-rendered shadow tree. This caused template rendering to be skipped. Now checks `this.shadowRoot.childNodes` for Shadow DOM components and `this.childNodes` for Light DOM ones.
18
+
3
19
  ## 3.4.1
4
20
 
5
21
  ### Fixed
package/README.md CHANGED
@@ -168,7 +168,7 @@ class TaskList extends Symbiote {
168
168
  { name: 'Write docs' },
169
169
  ];
170
170
  init$ = {
171
- // Needs to be defined in init$ for bubbling binding to work
171
+ // Needs to be defined in init$ for pop-up binding to work
172
172
  onItemClick: () => {
173
173
  console.log('clicked!');
174
174
  },
@@ -186,7 +186,7 @@ TaskList.template = html`
186
186
 
187
187
  Items have their own state scope. Use the **`^` prefix** to reach higher-level component properties and handlers — `'^onItemClick'` binds to the parent's `onItemClick`, not the item's. Properties referenced via `^` must be defined in the parent's `init$`.
188
188
 
189
- ### Bubbling binding (`^`)
189
+ ### Pop-up binding (`^`)
190
190
 
191
191
  The `^` prefix works in any nested component template — it walks up the DOM tree to find the nearest ancestor that has the property registered in its data context (`init$` or `add$()`):
192
192
 
package/core/Symbiote.js CHANGED
@@ -99,8 +99,11 @@ export class Symbiote extends HTMLElement {
99
99
  }
100
100
  }
101
101
  // Resolve isoMode: hydrate if children exist, render template otherwise
102
+ // For Shadow DOM components, SSR content is in shadowRoot (declarative shadow DOM),
103
+ // not in light DOM childNodes (those are slot content)
102
104
  if (this.isoMode && !globalThis.__SYMBIOTE_SSR) {
103
- this.ssrMode = this.childNodes.length > 0;
105
+ let ssrContainer = this.shadowRoot || this;
106
+ this.ssrMode = ssrContainer.childNodes.length > 0;
104
107
  }
105
108
  let clientSSR = this.ssrMode && !globalThis.__SYMBIOTE_SSR;
106
109
  if (this.processInnerHtml || clientSSR) {
@@ -469,7 +472,7 @@ export class Symbiote extends HTMLElement {
469
472
  } else {
470
473
  if (this.#super.rootStyleSheets) {
471
474
  // Skip adopted sheets when hydrating SSR (inline <style> tags already present):
472
- let hydrating = this.ssrMode || (this.isoMode && this.childNodes.length > 0);
475
+ let hydrating = this.ssrMode || (this.isoMode && (this.shadowRoot || this).childNodes.length > 0);
473
476
  if (!hydrating) {
474
477
  /** @type {Document | ShadowRoot} */
475
478
  // @ts-expect-error
@@ -595,6 +598,9 @@ export class Symbiote extends HTMLElement {
595
598
  * @param {Boolean} [silentCheck]
596
599
  */
597
600
  getCssData(propName, silentCheck = false) {
601
+ if (globalThis.__SYMBIOTE_SSR) {
602
+ return null;
603
+ }
598
604
  if (!this.#cssDataCache) {
599
605
  this.#cssDataCache = Object.create(null);
600
606
  }
@@ -636,6 +642,12 @@ export class Symbiote extends HTMLElement {
636
642
  * @param {any} [initValue] Uses empty string by default to make value useful in template
637
643
  */
638
644
  bindCssData(propName, initValue = '') {
645
+ if (Symbiote.#devMode && (this.ssrMode || this.isoMode)) {
646
+ console.warn(
647
+ `[Symbiote dev] <${this.localName}>: CSS data binding "${propName}" will not read computed styles during SSR. `
648
+ + 'The init value will be used instead.'
649
+ );
650
+ }
639
651
  if (!this.#boundCssProps) {
640
652
  this.#boundCssProps = new Set();
641
653
  }
@@ -5,7 +5,7 @@ export const DICT = {
5
5
  ATTR_BIND_PX: '@',
6
6
  // Shared prop prefix:
7
7
  SHARED_CTX_PX: '*',
8
- // Inherited parent prop prefix:
8
+ // Pop-up parent prop prefix:
9
9
  PARENT_CTX_PX: '^',
10
10
  // Named data context property splitter:
11
11
  NAMED_CTX_SPLTR: '/',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@symbiotejs/symbiote",
4
- "version": "3.4.1",
4
+ "version": "3.4.3",
5
5
  "description": "Symbiote.js - zero-dependency close-to-platform frontend library to build super-powered web components",
6
6
  "author": "team@rnd-pro.com",
7
7
  "license": "MIT",
@@ -20,7 +20,7 @@ export class Symbiote<S> extends HTMLElement {
20
20
  initCallback(): void;
21
21
  renderCallback(): void;
22
22
  render(template?: string | DocumentFragment, shadow?: boolean): void;
23
- ssrMode: boolean;
23
+ ssrMode: any;
24
24
  init$: S;
25
25
  cssInit$: {
26
26
  [x: string]: any;
@@ -1 +1 @@
1
- {"version":3,"file":"Symbiote.d.ts","sourceRoot":"","sources":["../../core/Symbiote.js"],"names":[],"mappings":";;AAm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