Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/core/src/components/BubbleList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ function initStyle() {
);
}

onMounted(() => {
initStyle();
});

watch(
() => [props.maxHeight, props.btnIconSize],
() => {
initStyle();
},
{
immediate: true
}
);
Comment on lines 44 to 52
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

SSR-safety: immediate watcher invokes DOM code during SSR; also risks global CSS var clobbering

immediate: true runs the watcher callback at setup time. In SSR that executes on the server, so initStyle() will access document and crash. Additionally, writing CSS vars on document.documentElement creates cross-instance interference.

  • Minimal fix: guard DOM access inside initStyle().
function initStyle() {
  if (typeof window === 'undefined' || typeof document === 'undefined') return;
  const root = document.documentElement;
  root.style.setProperty('--el-bubble-list-max-height', props.maxHeight || '100%');
  root.style.setProperty('--el-bubble-list-btn-size', `${props.btnIconSize}px`);
}
  • Recommended (scoped) approach: bind CSS vars on the component root instead of mutating documentElement to avoid conflicts and be SSR-friendly:
const cssVars = computed(() => ({
  '--el-bubble-list-max-height': props.maxHeight || '100%',
  '--el-bubble-list-btn-size': `${props.btnIconSize}px`,
}));

Template (on the wrapper div):

<div class="el-bubble-list-wrapper" :style="cssVars">

Please confirm whether SSR is a requirement for this library; if yes, we should at least add the DOM guard now, and consider the scoped CSS vars approach next.


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Repository root: $(pwd)"

echo "--- file exists check ---"
if [ -f packages/core/src/components/BubbleList/index.vue ]; then
  echo "FOUND: packages/core/src/components/BubbleList/index.vue"
else
  echo "MISSING: packages/core/src/components/BubbleList/index.vue"
fi

echo "--- show file (first 300 lines) ---"
sed -n '1,300p' packages/core/src/components/BubbleList/index.vue || true

echo "--- search for relevant symbols in file ---"
rg -n --hidden --no-ignore-vcs --color never "initStyle|documentElement|document\.|setProperty|immediate:\s*true|watch\(" packages/core/src/components/BubbleList/index.vue || true

echo "--- grep for initStyle definition elsewhere ---"
rg -n --hidden --no-ignore-vcs --color never "function\s+initStyle|const\s+initStyle\s*=" || true

Length of output: 8723


Fix SSR-safety: guard DOM access and avoid mutating documentElement

initStyle() writes CSS vars to document.documentElement and the watcher uses immediate: true — this runs during SSR and will throw.

  • Minimal fix: guard DOM access in initStyle():
function initStyle() {
  if (typeof window === 'undefined' || typeof document === 'undefined') return;
  const root = document.documentElement;
  root.style.setProperty('--el-bubble-list-max-height', props.maxHeight || '100%');
  root.style.setProperty('--el-bubble-list-btn-size', `${props.btnIconSize}px`);
}
  • Recommended (scoped) refactor: compute CSS vars and bind to the component root instead of mutating documentElement:
const cssVars = computed(() => ({
  '--el-bubble-list-max-height': props.maxHeight || '100%',
  '--el-bubble-list-btn-size': `${props.btnIconSize}px`,
}));

template:

<div class="el-bubble-list-wrapper" :style="cssVars">

Location: packages/core/src/components/BubbleList/index.vue — initStyle() + watch(...) (lines ~33–52).

🤖 Prompt for AI Agents
In packages/core/src/components/BubbleList/index.vue around lines 33 to 52,
initStyle() mutates document.documentElement and the watcher is immediate,
causing SSR crashes; either guard DOM access at the top of initStyle() and
return early when window or document is undefined, and then keep setting CSS
vars on document.documentElement, or better compute a scoped cssVars reactive
object from props and bind it to the component root element's style (replace
writing to document.documentElement) and remove DOM mutation in initStyle();
ensure the watcher no longer performs direct DOM writes during SSR.


Expand Down