@viewfly/platform-browser 2.2.0 → 3.0.0-alpha.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.
@@ -1,15 +1,16 @@
1
1
  import { ElementNamespace, NativeRenderer } from '@viewfly/core';
2
2
  export declare class DomRenderer extends NativeRenderer<HTMLElement, Text> {
3
- static NAMESPACES: Record<string, string>;
4
- propMap: Record<string, Record<string, string>>;
3
+ private static readonly XLINK_NS;
5
4
  /**
6
- * IDL 属性赋 `''` 会被转成数字 0(如 maxLength/minLength),无法表示「未设置」。
7
- * 这些键在移除时应删掉对应 content attribute。
5
+ * React/JSX xlink* 与 `xlink:` 开头的属性在 SVG/Math 等中须走 XLink 命名空间。
6
+ * 旧实现把 `xlink:` 后接的名字误当作 namespaceURI,且 `xlinkHref` 会退成普通 setAttribute 导致非标准属性名。
8
7
  */
9
- private static readonly REMOVE_VIA_ATTRIBUTE;
8
+ private static readonly XLINK_IDL_TO_LOCAL;
9
+ static NAMESPACES: Record<string, string>;
10
+ propMap: Record<string, Record<string, string>>;
10
11
  createElement(name: string, namespace: ElementNamespace): HTMLElement;
11
12
  createTextNode(textContent: string): Text;
12
- appendChild(parent: HTMLElement, newChild: any): void;
13
+ appendChild(parent: HTMLElement, newChild: HTMLElement | Text): void;
13
14
  prependChild(parent: HTMLElement, newChild: HTMLElement | Text): void;
14
15
  insertAfter(newNode: HTMLElement | Text, ref: HTMLElement | Text): void;
15
16
  remove(node: HTMLElement | Text): void;
@@ -23,6 +24,12 @@ export declare class DomRenderer extends NativeRenderer<HTMLElement, Text> {
23
24
  unListen(node: HTMLElement, type: string, callback: (ev: any) => any): void;
24
25
  syncTextContent(target: Text, content: string): void;
25
26
  getNameSpace(type: string, namespace: ElementNamespace): string | void;
27
+ /**
28
+ * SVG / MathML 等非 HTML 下无 HTML5 的「反射 IDL」表;通常用属性字符串表示,false/空串/非数常表示不输出该属性。
29
+ */
30
+ private static isXmlAttributeUnsetValue;
31
+ private setNamespacedPresentation;
32
+ private clearNamespacedPresentation;
26
33
  private normalizedEventType;
27
34
  private insertBefore;
28
35
  }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * HTML 反射 IDL 属性:在「与 default / 未设」一致时须 removeAttribute,不能写 `node[idl] = ''`,
3
+ * 否则会出现空 content 属性、错误约束(如 `pattern=""`、`maxLength=0` 等)。
4
+ * @see https://html.spec.whatwg.org/ 2.3.1 Reflected attributes
5
+ */
6
+ /**
7
+ * 解析后的 IDL 名 -> content attribute 名。removeProperty 命中时仅 `removeAttribute(name)`。
8
+ */
9
+ export declare const IDL_TO_CONTENT_ATTR: Readonly<Record<string, string>>;
10
+ /**
11
+ * setProperty 时,若把 `false`、`''` 或非有限 number 当「不设置/默认」,应走 remove。
12
+ * 不在此集合的 IDL 由通用逻辑或单独分支处理;布尔见上表排除。
13
+ */
14
+ export declare const IDL_FALSY_OR_NONFINITE_REMOVES: ReadonlySet<string>;
15
+ /**
16
+ * 是否应把 setProperty 改为 remove(`null`/`undefined` 由 setProperty 开头处理,此处不返回 true)。
17
+ * `false`、`''`、非有限数(NaN、±∞)在允许列表上时视为与「未设」同义。
18
+ */
19
+ export declare function isUnsetLikeReflectedIdlValue(resolvedIdlKey: string, value: unknown): boolean;
20
+ /**
21
+ * 由 IDL 名取 content attribute 名,无则 undefined。
22
+ */
23
+ export declare function getContentAttrNameForIdl(resolvedIdlKey: string): string | void;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './create-app';
2
- export * from './create-portal';
3
2
  export * from './html-renderer';
4
3
  export * from './dom-renderer';
4
+ export * from './html-idl-reflection';
5
+ export * from './xml-jsx-attr-name';
5
6
  export * from './jsx-dom';