File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
mkdocs_git_revision_date_localized_plugin/js Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
// Script to ensure timeago keeps working when
2
2
// used with mkdocs-material's instant loading feature
3
3
4
- if (
5
- typeof app !== "undefined" &&
6
- typeof app . document$ !== "undefined"
7
- ) {
8
- app . document$ . subscribe ( function ( ) {
4
+ if ( typeof document$ !== "undefined" ) {
5
+ document$ . subscribe ( function ( ) {
9
6
var nodes = document . querySelectorAll ( '.timeago' ) ;
10
- var locale = nodes [ 0 ] . getAttribute ( 'locale' ) ;
11
- timeago . render ( nodes , locale ) ;
7
+ if ( nodes . length > 0 ) {
8
+ var locale = nodes [ 0 ] . getAttribute ( 'locale' ) ;
9
+ timeago . render ( nodes , locale ) ;
10
+ }
12
11
} )
13
12
} else {
14
13
var nodes = document . querySelectorAll ( '.timeago' ) ;
15
- var locale = nodes [ 0 ] . getAttribute ( 'locale' ) ;
16
- timeago . render ( nodes , locale ) ;
14
+ if ( nodes . length > 0 ) {
15
+ var locale = nodes [ 0 ] . getAttribute ( 'locale' ) ;
16
+ timeago . render ( nodes , locale ) ;
17
+ }
17
18
}
You can’t perform that action at this time.
0 commit comments