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

Function eventsMixin

static/vuejs/vue.runtime.js:1842–1936  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

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

Callers 1

vue.runtime.jsFile · 0.70

Calls 2

toArrayFunction · 0.70
hyphenateFunction · 0.50

Tested by

no test coverage detected