PageSourceSearch

http://www.beloga.xyz/vue-turbolinks-2.2.2/index.js

js beloga.xyz collected 2026-09-29 03:23:24 UTC 1,091 bytes, 43 lines download raw bytes

1function handleVueDestruction(vue) {
2  const event = vue.$options.destroyEvent || defaultEvent();
3
4  document.addEventListener(event, function teardown() {
5    vue.$destroy();
6    document.removeEventListener(event, teardown);
7  });
8}
9
10const Mixin = {
11  beforeMount: function() {
12    // If this is the root component, we want to cache the original element contents to replace later
13    // We don't care about sub-components, just the root
14    if (this === this.$root && this.$el) {
15      handleVueDestruction(this);
16
17      // cache original element
18      this.$cachedHTML = this.$el.outerHTML;
19
20      // register root hook to restore original element on destroy
21      this.$once('hook:destroyed', function() {
22        if( this.$el.parentNode )
23          this.$el.outerHTML = this.$cachedHTML
24      });
25    }
26  }
27};
28
29function plugin(Vue, options) {
30  // Install a global mixin
31  Vue.mixin(Mixin)
32}
33
34function defaultEvent() {
35  if (typeof Turbo !== 'undefined') {
36    return 'turbo:visit';
37  }
38
39  return 'turbolinks:visit';
40}
41
42export { Mixin as turbolinksAdapterMixin };
43export default plugin;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.