Skip to content

Commit 066cb1e

Browse files
fixes #2635
1 parent 19b9a34 commit 066cb1e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/browser/common/util/tags/set-mount-state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import define from '../misc/define'
66
* @param { Boolean } value - ..of the isMounted flag
77
*/
88
export default function setMountState(value) {
9-
const { isAnonymous } = this.__
9+
const { isAnonymous, skipAnonymous } = this.__
1010

1111
define(this, 'isMounted', value)
1212

13-
if (!isAnonymous) {
13+
if (!isAnonymous || !skipAnonymous) {
1414
if (value) this.trigger('mount')
1515
else {
1616
this.trigger('unmount')

test/specs/browser/riot/core.spec.js

+23
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,29 @@ describe('Riot core', function() {
784784
riot.settings.skipAnonymousTags = true
785785
})
786786

787+
it('the "riot.settings.skipAnonymousTags = false" option will let trigger the "mount" event on anonymous tags' , function() {
788+
riot.settings.skipAnonymousTags = false
789+
const spy = sinon.spy()
790+
791+
injectHTML('<riot-tmp></riot-tmp>')
792+
793+
riot.mixin({
794+
init() {
795+
this.on('mount', spy)
796+
}
797+
})
798+
799+
riot.tag('riot-tmp', '<div each="{ items }"></div>', function() {
800+
this.items = [1]
801+
})
802+
803+
var tag = riot.mount('riot-tmp')[0]
804+
tag.unmount()
805+
expect(spy).to.have.been.calledTwice
806+
807+
riot.settings.skipAnonymousTags = true
808+
})
809+
787810
it('the "updated" event gets properly triggered in a nested child', function(done) {
788811
injectHTML('<div id="updated-events-tester"></div>')
789812
var tag = riot.mount('#updated-events-tester', 'named-child-parent')[0],

0 commit comments

Comments
 (0)