PHP 8.2.30
Preview: element.js Size: 1.54 KB
/home/byroehnu/.trash/node_modules11/object-inspect/test/element.js

var inspect = require('../');
var test = require('tape');

test('element', function (t) {
    t.plan(3);
    var elem = {
        nodeName: 'div',
        attributes: [{ name: 'class', value: 'row' }],
        getAttribute: function (key) { return key; },
        childNodes: []
    };
    var obj = [1, elem, 3];
    t.deepEqual(inspect(obj), '[ 1, <div class="row"></div>, 3 ]');
    t.deepEqual(inspect(obj, { quoteStyle: 'single' }), "[ 1, <div class='row'></div>, 3 ]");
    t.deepEqual(inspect(obj, { quoteStyle: 'double' }), '[ 1, <div class="row"></div>, 3 ]');
});

test('element no attr', function (t) {
    t.plan(1);
    var elem = {
        nodeName: 'div',
        getAttribute: function (key) { return key; },
        childNodes: []
    };
    var obj = [1, elem, 3];
    t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
});

test('element with contents', function (t) {
    t.plan(1);
    var elem = {
        nodeName: 'div',
        getAttribute: function (key) { return key; },
        childNodes: [{ nodeName: 'b' }]
    };
    var obj = [1, elem, 3];
    t.deepEqual(inspect(obj), '[ 1, <div>...</div>, 3 ]');
});

test('element instance', function (t) {
    t.plan(1);
    var h = global.HTMLElement;
    global.HTMLElement = function (name, attr) {
        this.nodeName = name;
        this.attributes = attr;
    };
    global.HTMLElement.prototype.getAttribute = function () {};

    var elem = new global.HTMLElement('div', []);
    var obj = [1, elem, 3];
    t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
    global.HTMLElement = h;
});

Directory Contents

Dirs: 1 × Files: 18

Name Size Perms Modified Actions
browser DIR
- drwxr-xr-x 2026-02-03 15:06:16
Edit Download
2.03 KB lrw-r--r-- 2026-02-03 15:06:14
Edit Download
451 B lrw-r--r-- 2026-02-03 15:06:16
Edit Download
400 B lrw-r--r-- 2026-02-03 15:06:16
Edit Download
1.54 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.50 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
683 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
2.17 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
372 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
514 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
255 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
6.48 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
4.83 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
268 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
2.26 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.49 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.51 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
302 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
8.21 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).