mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-21 19:32:34 +00:00
parent
eefc25de1a
commit
e30159875a
@ -337,7 +337,13 @@ NexT.utils = {
|
||||
}
|
||||
},
|
||||
|
||||
getScript: (url, {
|
||||
getScript: function(url, options = {}, legacyCondition) {
|
||||
if (typeof options === 'function') {
|
||||
return this.getScript(url, {
|
||||
condition: legacyCondition
|
||||
}).then(options);
|
||||
}
|
||||
const {
|
||||
condition = false,
|
||||
attributes: {
|
||||
id = '',
|
||||
@ -348,7 +354,8 @@ NexT.utils = {
|
||||
...otherAttributes
|
||||
} = {},
|
||||
parentNode = null
|
||||
} = {}) => new Promise((resolve, reject) => {
|
||||
} = options;
|
||||
return new Promise((resolve, reject) => {
|
||||
if (condition) {
|
||||
resolve();
|
||||
} else {
|
||||
@ -369,9 +376,14 @@ NexT.utils = {
|
||||
script.src = url;
|
||||
(parentNode || document.head).appendChild(script);
|
||||
}
|
||||
}),
|
||||
});
|
||||
},
|
||||
|
||||
loadComments: (selector) => new Promise((resolve) => {
|
||||
loadComments: function(selector, legacyCallback) {
|
||||
if (legacyCallback) {
|
||||
return this.loadComments(selector).then(legacyCallback);
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
const element = document.querySelector(selector);
|
||||
if (!CONFIG.comments.lazyload || !element) {
|
||||
resolve();
|
||||
@ -385,5 +397,6 @@ NexT.utils = {
|
||||
observer.disconnect();
|
||||
});
|
||||
intersectionObserver.observe(element);
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user