File tree 2 files changed +25
-2
lines changed
lib/browser/common/util/tags
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ import define from '../misc/define'
6
6
* @param { Boolean } value - ..of the isMounted flag
7
7
*/
8
8
export default function setMountState ( value ) {
9
- const { isAnonymous } = this . __
9
+ const { isAnonymous, skipAnonymous } = this . __
10
10
11
11
define ( this , 'isMounted' , value )
12
12
13
- if ( ! isAnonymous ) {
13
+ if ( ! isAnonymous || ! skipAnonymous ) {
14
14
if ( value ) this . trigger ( 'mount' )
15
15
else {
16
16
this . trigger ( 'unmount' )
Original file line number Diff line number Diff line change @@ -784,6 +784,29 @@ describe('Riot core', function() {
784
784
riot . settings . skipAnonymousTags = true
785
785
} )
786
786
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
+
787
810
it ( 'the "updated" event gets properly triggered in a nested child' , function ( done ) {
788
811
injectHTML ( '<div id="updated-events-tester"></div>' )
789
812
var tag = riot . mount ( '#updated-events-tester' , 'named-child-parent' ) [ 0 ] ,
You can’t perform that action at this time.
0 commit comments