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

Function eventsMixin

static/vuejs/vue.esm.js:1840–1934  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

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

Callers 1

vue.esm.jsFile · 0.70

Calls 2

toArrayFunction · 0.70
hyphenateFunction · 0.50

Tested by

no test coverage detected