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

Function _update

static/vuejs/vue.esm.js:5143–5201  ·  view source on GitHub ↗
(oldVnode, vnode)

Source from the content-addressed store, hash-verified

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

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