# KRB Image Cluster Replacement v2

## Why v1 failed

On `/community/weddings`, the Page Slot/DropTarget exposed `append()` but not `setChildren()`. v1 used `setChildren()` for exact in-place replacement, so it stopped with:

> parent has no setChildren(); cannot preserve replacement order

That was intentional safety rather than letting the gallery append to the wrong place.

## What changed in v2

v2 keeps the same targets and defaults, but the replacement helper now:

1. Uses `setChildren()` when available.
2. If not available, tries ordered insertion methods on the existing Image Cluster anchor / parent:
   - `anchor.before(component)`
   - `anchor.insertBefore(component)`
   - `parent.insertBefore(component, anchor)`
   - `parent.insert(component, index)`
   - `parent.insert(component, { index })`
   - `parent.insert(component, { before })`
   - `parent.prepend(component)` only when replacing index 0
3. Only removes the obsolete source Image Cluster after an ordered insert succeeds.
4. Reports available parent/anchor methods in `orderingMethods` so we can see what the Designer API exposes.
5. Keeps `allowAppendOnlyFallback: false` by default, so it will not append galleries out of order unless you explicitly choose that manual-cleanup fallback.

## Suggested Weddings test

1. Open `/community/weddings`.
2. Run v2 unchanged first (`dryRun: true`).
3. Confirm the output prefix is `KRB_IMAGE_CLUSTER_REPLACEMENT_V2_RESULT` and inspect `orderingMethods`.
4. If the dry-run shows an ordered method such as `before`, set `dryRun: false` and run on Weddings.
5. If it still reports no ordered insertion method, do **not** turn on append fallback unless you are happy to manually drag the new Slider Gallery into position and delete the old Image Cluster.

## Safety defaults

```js
CONFIG.dryRun = true;
CONFIG.runMode = 'current-page';
CONFIG.allowAppendOnlyFallback = false;
```

No publish/site/script/CMS/redirect/style operations are included.
