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

Function _update

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

Source from the content-addressed store, hash-verified

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

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