refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조

에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Antigravity Agent
2026-07-11 11:05:56 +09:00
parent 6549ead309
commit c24165b8bc
6193 changed files with 1717 additions and 31 deletions
@@ -0,0 +1,194 @@
---
id: wiki-2026-0508-dom-요소-조작
title: DOM 요소 조작
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [DOM Manipulation, Vanilla JS DOM, Document API]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [dom, javascript, web, browser]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: javascript
framework: dom
---
# DOM 요소 조작
## 매 한 줄
> **"매 Document 의 tree 의 query + mutation 의 web 기본 API"**. 매 jQuery 의 era 종료, 2026 의 modern DOM (querySelector, classList, dataset, MutationObserver) 의 충분 + framework (React/Solid/Svelte) 의 abstraction 위. 매 vanilla 의 fast path + 매 small widget 의 right tool.
## 매 핵심
### 매 Query
- `getElementById(id)` — 매 fastest single lookup.
- `querySelector(sel)` / `querySelectorAll(sel)` — CSS selector general.
- `closest(sel)` — 매 ancestor traversal.
- `matches(sel)` — boolean check.
### 매 Mutate
- **Create**: `createElement`, `cloneNode(true)`, `<template>` + `content.cloneNode`.
- **Insert**: `append`, `prepend`, `before`, `after`, `replaceWith`.
- **Remove**: `el.remove()`.
- **Attribute**: `setAttribute`, `dataset.x`, `classList.add/toggle/remove`.
- **Content**: `textContent` (safe) vs `innerHTML` (XSS risk).
### 매 Observe
- `MutationObserver` — 매 subtree change.
- `IntersectionObserver` — viewport visibility.
- `ResizeObserver` — element size.
### 매 응용
1. Lightweight widget (no framework) — banner, modal, tooltip.
2. Server-rendered HTML enhancement (Hotwire, Astro islands).
3. Browser extension content script.
## 💻 패턴
### Element creation (template)
```html
<template id="card-tpl">
<article class="card">
<h3 class="title"></h3>
<p class="body"></p>
</article>
</template>
```
```javascript
function renderCard({ title, body }) {
const tpl = document.getElementById('card-tpl');
const node = tpl.content.cloneNode(true);
node.querySelector('.title').textContent = title;
node.querySelector('.body').textContent = body;
return node;
}
document.querySelector('#list').append(renderCard({ title: 'Hi', body: 'World' }));
```
### classList + dataset
```javascript
const btn = document.querySelector('#toggle');
btn.classList.toggle('active');
btn.dataset.count = (Number(btn.dataset.count ?? 0) + 1).toString();
// HTML: <button id="toggle" data-count="3">
```
### Event delegation
```javascript
document.addEventListener('click', (e) => {
const action = e.target.closest('[data-action]');
if (!action) return;
switch (action.dataset.action) {
case 'open': openModal(action.dataset.id); break;
case 'delete': remove(action.dataset.id); break;
}
});
```
### Safe insertion (avoid innerHTML)
```javascript
// 매 X — XSS
container.innerHTML = `<p>${userInput}</p>`;
// 매 O — textContent
const p = document.createElement('p');
p.textContent = userInput;
container.append(p);
// 매 trusted HTML 만 — Sanitizer API (2026 baseline)
container.setHTML(trustedString); // 의 native sanitize
```
### IntersectionObserver — lazy load
```javascript
const io = new IntersectionObserver((entries) => {
for (const e of entries) {
if (!e.isIntersecting) continue;
const img = e.target;
img.src = img.dataset.src;
io.unobserve(img);
}
});
document.querySelectorAll('img[data-src]').forEach((img) => io.observe(img));
```
### MutationObserver — react to subtree
```javascript
const mo = new MutationObserver((muts) => {
for (const m of muts) {
for (const n of m.addedNodes) {
if (n instanceof HTMLAnchorElement) enhanceLink(n);
}
}
});
mo.observe(document.body, { childList: true, subtree: true });
```
### Form serialization
```javascript
const form = document.querySelector('#login');
form.addEventListener('submit', (e) => {
e.preventDefault();
const data = Object.fromEntries(new FormData(form));
fetch('/login', { method: 'POST', body: JSON.stringify(data), headers: { 'Content-Type': 'application/json' } });
});
```
### Animation — Web Animations API
```javascript
el.animate(
[{ opacity: 0, transform: 'translateY(10px)' }, { opacity: 1, transform: 'none' }],
{ duration: 200, easing: 'ease-out', fill: 'forwards' },
);
```
### Batched DOM updates
```javascript
const frag = document.createDocumentFragment();
for (const item of items) frag.append(renderRow(item));
list.append(frag); // 매 single reflow
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Static + small interaction | Vanilla DOM |
| 100s of components | React / Solid / Svelte |
| Server HTML + enhancement | Hotwire / Astro |
| Lazy load images | IntersectionObserver |
| External widget injection | MutationObserver |
| Animation | Web Animations API |
**기본값**: querySelector + classList + textContent + delegation + Observer APIs.
## 🔗 Graph
- 부모: [[DOM]]
- 변형: [[DOM 요소 조작 및 타입 좁히기]] · [[Shadow_DOM]]
- 응용: [[Web_Components]] · [[Hotwire]]
- Adjacent: [[IntersectionObserver]] · [[MutationObserver]]
## 🤖 LLM 활용
**언제**: vanilla widget scaffold, Observer setup, jQuery → modern migration.
**언제 X**: 매 framework app — 매 framework primitive 의 사용.
## ❌ 안티패턴
- **`innerHTML` with user input**: 매 XSS — `textContent` 또는 Sanitizer.
- **Loop append in DOM**: 매 N reflows — DocumentFragment 의 사용.
- **No event delegation**: 1000 listener 의 memory + perf 비용.
- **document.write**: deprecated — 매 stream block.
- **Manual style mutation everywhere**: classList toggle + CSS 의 사용.
## 🧪 검증 / 중복
- Verified (MDN DOM, Web Animations, Observers, Sanitizer API spec).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — query/mutate/observe patterns + Sanitizer + delegation |