Open
Description
When writing tests for the utils methods, I came across some logic that was confusing:
https://github.com/benjycui/jsonml.js/blob/master/lib/utils.js#L132
} else if (child || !parent.length) {
// append
parent.push(child);
This allows for some unclear behavior, particularly when allowing exception for a parent with no length.
- append a child to an empty parent array
const jml = [];
utils.appendChild(jml, '');
// jml === ['']
const jml = [];
utils.appendChild(jml, ['p', 'hello']);
// jml === [ ['p', 'hello'] ]
Is this a real use case or an edge case bug? I'm guessing this would never be desired and should probably not be allowed.
Metadata
Metadata
Assignees
Labels
No labels