1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
describe('hx-inherit attribute', function() {
beforeEach(function() {
this.server = makeServer()
clearWorkArea()
htmx.config.disableInheritance = true
})
afterEach(function() {
this.server.restore()
clearWorkArea()
htmx.config.disableInheritance = false
})
it('can disable inheritance', function() {
this.server.respondWith('GET', '/test', 'Test')
var div = make('<div hx-target="#cta">' +
'<button id="btn1" hx-get="/test"></button>' +
'<span id="cta">Click Me!</span>' +
'</div>')
var btn = byId('btn1')
btn.click()
this.server.respond()
btn.innerText.should.equal('Test')
})
it('can enable inheritance for all', function() {
this.server.respondWith('GET', '/test', 'Test')
var div = make('<div hx-target="#cta" hx-inherit="*">' +
'<button id="btn1" hx-get="/test"></button>' +
'<span id="cta">Click Me!</span>' +
'</div>')
var btn = byId('btn1')
var span = byId('cta')
btn.click()
this.server.respond()
btn.innerText.should.equal('')
span.innerText.should.equal('Test')
})
it('can enable inheritance by name', function() {
this.server.respondWith('GET', '/test', 'Test')
var div = make('<div hx-target="#cta" hx-inherit="hx-target">' +
'<button id="btn1" hx-get="/test"></button>' +
'<span id="cta">Click Me!</span>' +
'</div>')
var btn = byId('btn1')
var span = byId('cta')
btn.click()
this.server.respond()
btn.innerText.should.equal('')
span.innerText.should.equal('Test')
})
it('can enable inheritance by name (bad name, no inheritance)', function() {
this.server.respondWith('GET', '/test', 'Test')
var div = make('<div hx-target="#cta" hx-inherit="hx-swap">' +
'<button id="btn1" hx-get="/test"></button>' +
'<span id="cta">Click Me!</span>' +
'</div>')
var btn = byId('btn1')
var span = byId('cta')
btn.click()
this.server.respond()
btn.innerText.should.equal('Test')
span.innerText.should.equal('Click Me!')
})
it('can enable inheritance by name with multiple attributes', function() {
this.server.respondWith('GET', '/test', 'Test')
var div = make('<div hx-target="#cta" hx-swap="outerHTML" hx-inherit="hx-target hx-swap">' +
'<button id="btn1" hx-get="/test"></button>' +
'<div id="d2"><span id="cta">Click Me!</span></div>' +
'</div>')
var btn = byId('btn1')
var div = byId('d2')
btn.click()
this.server.respond()
div.innerHTML.should.equal('Test')
})
})
|