Skip to content

installV3ShadowPiercer ignores opts.debug — debug logging always enabled #1996

@devk03

Description

@devk03

Bug:installV3ShadowPiercer 中的 opts.debug 被忽略

文件: packages/core/lib/v3/dom/piercer.runtime.ts

V3ShadowPatchOptions 接口中定义了一个 debug?: boolean 选项:

export interface V3ShadowPatchOptions {
  debug?: boolean;
  tagExisting?: boolean;
}

但是,installV3ShadowPiercer 并没有使用 opts.debug,而是将
DEBUG 硬编码为 true,并在注释中也承认了这一点:

export function installV3ShadowPiercer(opts: V3ShadowPatchOptions = {}): void {
  // hardcoded debug (remove later if desired)
  const DEBUG = true;

这意味着无论调用方传入什么参数,console.info("[v3-piercer] attachShadow", ...)
都会在每次调用 attachShadow 时触发,V3ShadowPatchOptions 中的 debug 字段实际上成为了一个无效(未被使用)的 API。

期望行为:
DEBUG 应该基于 opts.debug ?? false 来设置,从而允许调用方控制日志输出的详细程度。

建议修复:

const DEBUG = opts.debug ?? false;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions