MCPcopy Create free account
hub / github.com/TruthHun/BookStack / eventsMixin

Function eventsMixin

static/vuejs/vue.runtime.esm.js:1836–1930  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

1834}
1835
1836function eventsMixin (Vue) {
1837 var hookRE = /^hook:/;
1838 Vue.prototype.$on = function (event, fn) {
1839 var this$1 = this;
1840
1841 var vm = this;
1842 if (Array.isArray(event)) {
1843 for (var i = 0, l = event.length; i < l; i++) {
1844 this$1.$on(event[i], fn);
1845 }
1846 } else {
1847 (vm._events[event] || (vm._events[event] = [])).push(fn);
1848 // optimize hook:event cost by using a boolean flag marked at registration
1849 // instead of a hash lookup
1850 if (hookRE.test(event)) {
1851 vm._hasHookEvent = true;
1852 }
1853 }
1854 return vm
1855 };
1856
1857 Vue.prototype.$once = function (event, fn) {
1858 var vm = this;
1859 function on () {
1860 vm.$off(event, on);
1861 fn.apply(vm, arguments);
1862 }
1863 on.fn = fn;
1864 vm.$on(event, on);
1865 return vm
1866 };
1867
1868 Vue.prototype.$off = function (event, fn) {
1869 var this$1 = this;
1870
1871 var vm = this;
1872 // all
1873 if (!arguments.length) {
1874 vm._events = Object.create(null);
1875 return vm
1876 }
1877 // array of events
1878 if (Array.isArray(event)) {
1879 for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
1880 this$1.$off(event[i$1], fn);
1881 }
1882 return vm
1883 }
1884 // specific event
1885 var cbs = vm._events[event];
1886 if (!cbs) {
1887 return vm
1888 }
1889 if (arguments.length === 1) {
1890 vm._events[event] = null;
1891 return vm
1892 }
1893 // specific handler

Callers 1

vue.runtime.esm.jsFile · 0.70

Calls 2

toArrayFunction · 0.70
hyphenateFunction · 0.50

Tested by

no test coverage detected