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

Function _update

static/vuejs/vue.runtime.common.js:5141–5199  ·  view source on GitHub ↗
(oldVnode, vnode)

Source from the content-addressed store, hash-verified

5139}
5140
5141function _update (oldVnode, vnode) {
5142 var isCreate = oldVnode === emptyNode;
5143 var isDestroy = vnode === emptyNode;
5144 var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
5145 var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
5146
5147 var dirsWithInsert = [];
5148 var dirsWithPostpatch = [];
5149
5150 var key, oldDir, dir;
5151 for (key in newDirs) {
5152 oldDir = oldDirs[key];
5153 dir = newDirs[key];
5154 if (!oldDir) {
5155 // new directive, bind
5156 callHook$1(dir, 'bind', vnode, oldVnode);
5157 if (dir.def && dir.def.inserted) {
5158 dirsWithInsert.push(dir);
5159 }
5160 } else {
5161 // existing directive, update
5162 dir.oldValue = oldDir.value;
5163 callHook$1(dir, 'update', vnode, oldVnode);
5164 if (dir.def && dir.def.componentUpdated) {
5165 dirsWithPostpatch.push(dir);
5166 }
5167 }
5168 }
5169
5170 if (dirsWithInsert.length) {
5171 var callInsert = function () {
5172 for (var i = 0; i < dirsWithInsert.length; i++) {
5173 callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
5174 }
5175 };
5176 if (isCreate) {
5177 mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert);
5178 } else {
5179 callInsert();
5180 }
5181 }
5182
5183 if (dirsWithPostpatch.length) {
5184 mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
5185 for (var i = 0; i < dirsWithPostpatch.length; i++) {
5186 callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
5187 }
5188 });
5189 }
5190
5191 if (!isCreate) {
5192 for (key in oldDirs) {
5193 if (!newDirs[key]) {
5194 // no longer present, unbind
5195 callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
5196 }
5197 }
5198 }

Callers 1

updateDirectivesFunction · 0.70

Calls 4

normalizeDirectives$1Function · 0.70
callHook$1Function · 0.70
mergeVNodeHookFunction · 0.70
callInsertFunction · 0.70

Tested by

no test coverage detected