fix: interactions are builder-only for users without unfiltered_html (P16)
Divi's frontend applies the interaction effect "Attribute" with setAttribute (e.g. an onclick handler) and sets cookies; *.decoration.interactions joins the S7 gate in ValueCleaner, which also covers removals and StoredNodeGuard. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -376,4 +376,33 @@ final class AttrWriterTest extends TestCase
|
||||
$heading = ComposeFixture::attrWriter()->apply('divi/heading', [], ['module.meta.adminLabel' => ['desktop' => 'x']], 'attrs');
|
||||
self::assertSame([], $heading['errors'], 'only section type and specialty columns are structure');
|
||||
}
|
||||
|
||||
/** Ruling P16: interactions (setAttribute on the frontend) only with unfiltered_html – set and removal. */
|
||||
public function testInteractionsNeedUnfilteredHtml(): void
|
||||
{
|
||||
$interaction = ['interactions' => [[
|
||||
'trigger' => 'click',
|
||||
'effect' => 'addAttribute',
|
||||
'attributeName' => 'data-probe',
|
||||
'attributeValue' => '1',
|
||||
]]];
|
||||
$changes = ['module.decoration.interactions' => ['desktop' => $interaction]];
|
||||
|
||||
$editor = ComposeFixture::attrWriter()->apply('divi/text', self::TEXT, $changes, 'attrs');
|
||||
self::assertSame(self::TEXT, $editor['attrs']);
|
||||
self::assertStringContainsString('nur im Divi-Builder', $editor['errors']['attrs.module.decoration.interactions']);
|
||||
|
||||
$removal = ComposeFixture::attrWriter()->apply('divi/text', self::TEXT, ['module.decoration.interactions' => null], 'attrs');
|
||||
self::assertStringContainsString('nur im Divi-Builder', $removal['errors']['attrs.module.decoration.interactions']);
|
||||
|
||||
$admin = ComposeFixture::attrWriter(true)->apply('divi/text', self::TEXT, $changes, 'attrs');
|
||||
self::assertSame([], $admin['errors']);
|
||||
self::assertSame(
|
||||
'data-probe',
|
||||
$admin['attrs']['module']['decoration']['interactions']['desktop']['value']['interactions'][0]['attributeName']
|
||||
);
|
||||
$adminRemoval = ComposeFixture::attrWriter(true)->apply('divi/text', $admin['attrs'], ['module.decoration.interactions' => null], 'attrs');
|
||||
self::assertSame([], $adminRemoval['errors']);
|
||||
self::assertArrayNotHasKey('interactions', $adminRemoval['attrs']['module']['decoration'] ?? []);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user