{'data-x'} = 'x'; $el->{'data-list'} = [1, 2, 3]; $el->{'data-arr'} = ['a' => 1]; Assert::same('
', (string) $el); }); test('function', function () { $el = Html::el('div'); $el->data('a', 'one'); $el->data('b', 'two'); $el->data('list', [1, 2, 3]); $el->data('arr', ['a' => 1]); Assert::same('one', $el->{'data-a'}); Assert::same('', (string) $el); }); test('special values', function () { $el = Html::el('div'); $el->data('top', null); $el->data('t', true); $el->data('f', false); $el->data('x', ''); Assert::same('', (string) $el); }); test('setter', function () { $el = Html::el('div'); $el->setAttribute('data-x', 'x'); $el->setAttribute('data-list', [1, 2, 3]); $el->setAttribute('data-arr', ['a' => 1]); $el->setAttribute('top', null); $el->setAttribute('active', false); Assert::same('', (string) $el); }); test('', function () { $el = Html::el('div'); $el->data = 'simple'; Assert::same('', (string) $el); $el->data('simple2'); Assert::same('', (string) $el); $el->setAttribute('data', 'simple3'); Assert::same('', (string) $el); });