describe('__atributeValue() unit tests', function() {
it(':append modifier appends to inherited value', function () {
const container = createDisconnectedHTML(
'
' +
' ' +
'
'
);
const button = container.querySelector('button');
const result = htmx.__attributeValue(button, 'hx-include');
assert.equal(result, '.parent,.child');
});
it(':append modifier works without inherited value', function () {
const button = createDisconnectedHTML('');
const result = htmx.__attributeValue(button, 'hx-include');
assert.equal(result, '.child');
});
it(':append modifier works with multiple inheritance levels', function () {
const container = createDisconnectedHTML(
'' +
'
' +
' ' +
'
' +
'
'
);
const button = container.querySelector('button');
const result = htmx.__attributeValue(button, 'hx-vals');
assert.equal(result, '"a":1,"b":2');
});
it(':inherited still works normally', function () {
const container = createDisconnectedHTML(
'' +
' ' +
'
'
);
const button = container.querySelector('button');
const result = htmx.__attributeValue(button, 'hx-include');
assert.equal(result, '.parent');
});
it('direct attribute takes precedence over :append', function () {
const container = createDisconnectedHTML(
'' +
' ' +
'
'
);
const button = container.querySelector('button');
const result = htmx.__attributeValue(button, 'hx-include');
assert.equal(result, '.direct');
});
it(':inherited:append modifier works', function () {
const container = createDisconnectedHTML(
'' +
'
' +
' ' +
'
' +
'
'
);
const button = container.querySelector('button');
const result = htmx.__attributeValue(button, 'hx-include');
assert.equal(result, '.grandparent,.parent,.child');
});
it(':inherited:append can be inherited by descendants', function () {
const container = createDisconnectedHTML(
'' +
' ' +
'
'
);
const button = container.querySelector('button');
const result = htmx.__attributeValue(button, 'hx-include');
assert.equal(result, '.parent');
});
});