Best JavaScript code snippet using playwright-internal
jquery.quiz.js
Source:jquery.quiz.js
1(function( $ ) {2function isundef(x, y) {3 return (x == undefined) ? y : x;4}5QuizSingleHandler = function (question, idQuestion) {6 this.question = question;7 this.idQuestion = idQuestion;8 this.hintsShown = 0;9 this.attempts = 0;10}11QuizSingleHandler.prototype = {12 13 makeCorrection: function(self) {14 // when used as a callback, self will be passed as parameter,15 // since 'this' will be overridden by jquery16 var self = isundef(self, this);17 self.question.data('submitted', true);18 self.attempts += 1;19 console.log(self.attempts);20 21 $('.quiz-radio:checked', self.question).each(function() {22 var $radio = $(this);23 var $option = $radio.parent();24 25 if ( $option.hasClass('quiz-answer') ) {26 $option.addClass('quiz-correct');27 $option.parents('div.quiz').data('attempts', self.attempts);28 $option.parents('div.quiz').data('status', 'correct');29 self.explanationVisible(true); 30 } else {31 $option.addClass('quiz-wrong');32 $option.parents('div.quiz').data('attempts', self.attempts);33 $option.parents('div.quiz').data('status', 'wrong');34 };35 });36 },37 38 clear: function(self) { 39 var self = isundef(self, this);40 $('.quiz-radio', self.question).removeAttr('checked');41 self.clearCorrection();42 },43 44 clearCorrection: function(self) {45 var self = isundef(self, this);46 47 if ( self.question.data('submitted') == true ) {48 $('.quiz-option', self.question).removeClass('quiz-correct quiz-wrong');49 self.question.data('submitted', false);50 } 51 52 self.explanationVisible(false); 53 self.hintVisible(false);54 },55 56 showAnswer: function(self) {57 var self = isundef(self, this);58 self.clear();59 60 $('.quiz-answer', self.question).each(function() {61 $(this).addClass('quiz-correct');62 $(this).find('.quiz-radio').attr('checked', 'checked');63 });64 65 self.question.data('submitted', true);66 self.explanationVisible(true);67 },68 69 hintVisible: function(mode, self) {70 var self = isundef(self, this);71 mode = (mode) ? 'block' : 'none';72 $('.quiz-hint', self.question).each(function() {73 $(this).css('display', mode);74 // $(this).find('li:lt(' + self.hintsShown + 1, ')').show();75 // console.log(self.hintsShown);76 // self.hintsShown++;77 });78 },79 80 toggleHint: function(self) {81 var self = isundef(self, this);82 83 $('.quiz-hint', self.question).each(function() {84 if ( $(this).css('display') == 'none' )85 self.hintVisible(true);86 else87 self.hintVisible(false);88 });89 },90 91 explanationVisible: function(mode, self) {92 var self = isundef(self, this);93 94 mode = (mode) ? 'block' : 'none';95 96 $('.quiz-explanation', self.question).each(function() {97 // commented out to display answer as modal98 // $(this).css('display', mode); 99 $(this).css('display', 'none');100 });101 },102 103 init: function() { 104 var self = this;105 106 // added data-numOption to the template107 var template = Mustache.compile('<input type="radio" class="quiz-radio" ' +108 'name="quiz-question-{{idQuestion}}-options" value="{{label}}"' +109 'data-numOption="{{numOption}}"' +110 'id="quiz-question-{{idQuestion}}-option-{{numOption}}"/>' +111 '<label for="quiz-question-{{idQuestion}}-option-{{numOption}}">{{label}}</label>' 112 );113 114 /*115 var template = Mustache.compile('<label for="quiz-question-{{idQuestion}}-option-{{numOption}}" class="radio">' +116 '<input type="radio" class="quiz-radio" ' +117 'name="quiz-question-{{idQuestion}}-options" value="{{label}}"' +118 'data-numOption="{{numOption}}"' +119 'id="quiz-question-{{idQuestion}}-option-{{numOption}}"/>' +120 '{{label}}</label>' 121 );122 */123 124 // creates radio buttons for the quiz125 var numOption = 0;126 $('.quiz-answer, .quiz-option', self.question).each(function() {127 var $this = $(this);128 $this.addClass('quiz-option');129 $this.html(template({130 idQuestion: self.idQuestion, 131 numOption: ++numOption, 132 label: $this.text() 133 }));134 });135 136 // bind clear to the quiz-clear elements, if any137 $('.quiz-clear', self.question).each(function() {138 $(this).bind('click.clear', function() { self.clear(self) });139 });140 141 // clear correction if there are correct/wrong classes but the options checked changed142 $('.quiz-radio', self.question).each(function() {143 $(this).bind('click.clearCorrection', function() { self.clearCorrection(self) });144 });145 // bind makeCorrection to the quiz-submit elements, if any146 $('.quiz-submit', self.question).each(function() {147 $(this).bind('click.makeCorrection', function() { self.makeCorrection(self) });148 });149 150 // bind makeCorrection to the quiz-submit elements, if any151 $('.quiz-show-answer', self.question).each(function() {152 $(this).bind('click.showAnswer', function() { self.showAnswer(self) });153 });154 155 $('.quiz-toggle-hint', self.question).each(function() {156 $(this).bind('click.toggleHint', function() { self.toggleHint(self) });157 });158 self.hintVisible(false);159 self.explanationVisible(false);160 }161}162QuizMultipleHandler = function (question, idQuestion) {163 this.question = question;164 this.idQuestion = idQuestion;165}166QuizMultipleHandler.prototype = {167 _individual: function(self) {168 var self = isundef(self, this);169 self.question.data('submitted', true);170 171 var isCorrect = true;172 $('.quiz-checkbox', self.question).each(function() {173 var $checkbox = $(this);174 var $option = $checkbox.parent();175 176 isCorrect = isCorrect && 177 ($option.hasClass('quiz-answer') == $checkbox.is(':checked'));178 });179 180 $('.quiz-checkbox:checked', self.question).each(function() {181 var $checkbox = $(this);182 var $option = $checkbox.parent();183 184 if ( $option.hasClass('quiz-answer') == $checkbox.is(':checked') )185 $option.addClass('quiz-correct');186 else187 $option.addClass('quiz-wrong');188 });189 190 if ( isCorrect ) 191 self.explanationVisible(true);192 },193 194 _whole: function(self) {195 var self = isundef(self, this);196 self.question.data('submitted', true);197 198 var isCorrect = true;199 $('.quiz-checkbox', self.question).each(function() {200 var $checkbox = $(this);201 var $option = $checkbox.parent();202 203 isCorrect = isCorrect && 204 ($option.hasClass('quiz-answer') == $checkbox.is(':checked'));205 });206 207 $('.quiz-checkbox:checked', self.question).each(function() {208 var $checkbox = $(this);209 var $option = $checkbox.parent();210 211 if ( isCorrect )212 $option.addClass('quiz-correct'); 213 else214 $option.addClass('quiz-wrong');215 });216 217 if ( isCorrect ) 218 self.explanationVisible(true);219 },220 221 clear: function(self) { 222 var self = isundef(self, this);223 $('.quiz-checkbox', self.question).removeAttr('checked');224 self.clearCorrection();225 },226 227 clearCorrection: function(self) {228 var self = isundef(self, this);229 230 if ( self.question.data('submitted') == true ) {231 $('.quiz-option', self.question).removeClass('quiz-correct quiz-wrong');232 self.question.data('submitted', false);233 } 234 235 self.explanationVisible(false); 236 },237 238 showAnswer: function(self) {239 var self = isundef(self, this);240 self.clear();241 242 $('.quiz-answer', self.question).each(function() {243 var $this = $(this);244 $this.addClass('quiz-correct');245 246 $('.quiz-checkbox', $this).each(function() {247 $(this).attr('checked', 'checked');248 });249 });250 251 self.question.data('submitted', true);252 self.explanationVisible(true);253 },254 255 hintVisible: function(mode, self) {256 var self = isundef(self, this);257 mode = (mode) ? 'block' : 'none';258 $('.quiz-hint', self.question).each(function() {259 $(this).css('display', mode);260 });261 },262 263 toggleHint: function(self) {264 var self = isundef(self, this);265 266 $('.quiz-hint', self.question).each(function() {267 if ( $(this).css('display') == 'none' )268 self.hintVisible(true);269 else270 self.hintVisible(false);271 });272 },273 274 explanationVisible: function(mode, self) {275 var self = isundef(self, this);276 277 mode = (mode) ? 'block' : 'none';278 279 $('.quiz-explanation', self.question).each(function() {280 $(this).css('display', 'none');281 // $(this).css('display', mode);282 });283 },284 285 init: function() { 286 var self = this;287 288 var template = Mustache.compile('<input type="checkbox" class="quiz-checkbox" ' +289 'id="quiz-question-{{idQuestion}}-option-{{numOption}}"/>' +290 '<label for="quiz-question-{{idQuestion}}-option-{{numOption}}">{{label}}</label>');291 292 var numOption = 0;293 $('.quiz-answer, .quiz-option', self.question).each(function() {294 var $this = $(this);295 $this.addClass('quiz-option');296 $this.html(template({297 idQuestion: self.idQuestion, 298 numOption: ++numOption, 299 label: $this.html() 300 }));301 });302 303 if ( self.question.attr('data-individual') != undefined ) {304 self.makeCorrection = self._individual;305 } else {306 self.makeCorrection = self._whole;307 }308 309 $('.quiz-clear', self.question).each(function() {310 $(this).bind('click.clear', function() { self.clear(self) });311 });312 313 $('.quiz-checkbox', self.question).each(function() {314 $(this).bind('click.clearCorrection', function() { self.clearCorrection(self) });315 });316 317 $('.quiz-submit', self.question).each(function() {318 $(this).bind('click.makeCorrection', function() { self.makeCorrection(self) });319 });320 321 $('.quiz-show-answer', self.question).each(function() {322 $(this).bind('click.showAnswer', function() { self.showAnswer(self) });323 });324 325 $('.quiz-toggle-hint', self.question).each(function() {326 $(this).bind('click.toggleHint', function() { self.toggleHint(self) });327 });328 self.hintVisible(false);329 self.explanationVisible(false);330 }331}332QuizTextHandler = function(question, idQuestion) { 333 this.question = question;334 this.idQuestion = idQuestion;335}336QuizTextHandler.prototype = {337 338 makeCorrection: function(self){339 var self = isundef(self, this);340 self.clearCorrection();341 self.question.data('submitted', true);342 343 $(".quiz-answerbox", self.question).each(function(){344 var userAnswer = parseFloat($(this).val());345 self.answer = $(this).data("answer");346 if (Math.abs(userAnswer - self.answer)/self.answer < 0.02){347 self.explanationVisible(true);348 $(this).addClass('quiz-correct')349 } else {350 $(this).addClass('quiz-wrong')351 }352 });353 },354 355 makeCorrection2: function(self) {356 var self = isundef(self, this);357 self.clearCorrection();358 self.question.data('submitted', true);359 var userAnswer = '';360 $('.quiz-answerbox', self.question).each(function() {361 var $answerbox = $(this);362 userAnswer = $answerbox.val();363 self.answer = $(this).attr("data-answer");364 });365 366 if ( !self.caseSensitive ) {367 userAnswer = userAnswer.toLowerCase();368 if ( self.answer )369 self.answer = self.answer.toLowerCase();370 }371 372 if ( !self.notrim ) {373 userAnswer = $.trim(userAnswer);374 self.answer = $.trim(self.answer);375 if ( self.answer )376 self.answer = self.answer.toLowerCase();377 }378 379 if ( userAnswer == self.answer || self.validator(userAnswer) ) {380 self.explanationVisible(true);381 $('.quiz-answerbox', self.question).each(function() {382 $(this).addClass('quiz-correct');383 });384 } else 385 $('.quiz-answerbox', self.question).each(function() {386 $(this).addClass('quiz-wrong');387 });388 },389 390 hintVisible: function(mode, self) {391 var self = isundef(self, this);392 mode = (mode) ? 'block' : 'none';393 $('.quiz-hint', self.question).each(function() {394 $(this).css('display', mode);395 });396 },397 398 toggleHint: function(self) {399 var self = isundef(self, this);400 401 $('.quiz-hint', self.question).each(function() {402 if ( $(this).css('display') == 'none' )403 self.hintVisible(true);404 else405 self.hintVisible(false);406 });407 },408 409 clear: function(self) { 410 var self = isundef(self, this);411 $('.quiz-answerbox', self.question).val('');412 self.clearCorrection();413 },414 415 clearCorrection: function(self) {416 var self = isundef(self, this); 417 418 if ( self.question.data('submitted') == true ) {419 $('.quiz-answerbox', self.question).removeClass('quiz-correct quiz-wrong');420 self.question.data('submitted', false);421 } 422 423 self.explanationVisible(false); 424 },425 426 showAnswer: function(self) {427 // if ( self.answer == undefined ) 428 // return;429 430 var self = isundef(self, this);431 self.clear();432 433 $('.quiz-answerbox', self.question).each(function() {434 var $this = $(this);435 self.answer = $this.attr("data-answer");436 $this.val(self.answer);437 $this.addClass('quiz-correct');438 });439 440 self.question.data('submitted', true);441 self.explanationVisible(true);442 },443 444 explanationVisible: function(mode, self) {445 var self = isundef(self, this);446 447 mode = (mode) ? 'block' : 'none';448 449 $('.quiz-explanation', self.question).each(function() {450 $(this).css('display', 'none')451 // $(this).css('display', mode);452 });453 454 },455 456 init: function() {457 var self = this;458 459 self.answer = self.question.attr('data-answer');460 461 if ( self.question.attr('data-validator') != undefined )462 self.validator = eval("(" + self.question.attr('data-validator') + ")"); 463 464 self.validator = isundef(self.validator, function(x) { return false; });465 466 self.caseSensitive = self.question.attr('data-sensitive') != undefined;467 self.notrim = self.question.attr('data-notrim') != undefined; 468 469 $('.quiz-clear', self.question).each(function() {470 $(this).bind('click.clear', function() { self.clear(self) });471 });472 473 $('.quiz-submit', self.question).each(function() {474 $(this).bind('click.makeCorrection', function() { self.makeCorrection(self) });475 });476 477 $('.quiz-answerbox', self.question).each(function() {478 $(this).bind('change.clearCorrection', function() { self.clearCorrection(self) });479 });480 481 $('.quiz-show-answer', self.question).each(function() {482 $(this).bind('click.showAnswer', function() { self.showAnswer(self) });483 });484 485 $('.quiz-toggle-hint', self.question).each(function() {486 $(this).bind('click.toggleHint', function() { self.toggleHint(self) });487 }); 488 self.hintVisible(false);489 self.explanationVisible(false);490 }491}492$.quiz = function($context) {493 var self = $.quiz;494 // if no context is given, set it as document 495 $context = ($context == undefined) ? $(document) : $context;496 var handler = self.getHandler($context);497 498 // if it doesn't have a handler, check all children for handlers499 if ( handler == undefined ) {500 for (handler in self.handlers)501 $('.' + handler, $context).each(function() {502 var $this = $(this);503 var newQuiz = new self.handlers[handler]($this, self.getId($this));504 self.quizzes.push(newQuiz);505 newQuiz.init();506 });507 } // if it has, make it a quiz508 else {509 var newQuiz = new self.handlers[handler]($context, self.getId($context));510 self.quizzes.push(newQuiz);511 newQuiz.init();512 }513}514$.quiz.getId = function($element) {515 self.counter = (self.counter == undefined) ? 0 : self.counter;516 if ( $element.attr('id') != undefined )517 return $element.attr('id');518 else519 return ++self.counter;520}521$.quiz.getHandler = function($context) {522 for (var handler in $.quiz.handlers)523 if ( $context.hasClass(handler) ) 524 return handler;525 526 return undefined;527}528$.quiz.handlers = {529 'quiz-single': QuizSingleHandler,530 'quiz-multiple': QuizMultipleHandler,531 'quiz-text': QuizTextHandler532};533$.quiz.quizzes = [];534$.fn.quiz = function() {535 $.quiz(this);536 return this;537}...
build.js
Source:build.js
...241// jshint newcap: false242'use strict';243var VNode = require('./vnode');244var is = require('./is');245function isUndef(s) {246 return s === undefined;247}248function emptyNodeAt(elm) {249 return VNode(elm.tagName, {}, [], undefined, elm);250}251var emptyNode = VNode('', {}, [], undefined, undefined);252var insertedVnodeQueue;253function sameVnode(vnode1, vnode2) {254 return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;255}256function createKeyToOldIdx(children, beginIdx, endIdx) {257 var i,258 map = {},259 key;260 for (i = beginIdx; i <= endIdx; ++i) {261 key = children[i].key;262 if (!isUndef(key)) map[key] = i;263 }264 return map;265}266function createRmCb(parentElm, childElm, listeners) {267 return function () {268 if (--listeners === 0) parentElm.removeChild(childElm);269 };270}271var hooks = ['create', 'update', 'remove', 'destroy', 'pre', 'post'];272function init(modules) {273 var i,274 j,275 cbs = {};276 for (i = 0; i < hooks.length; ++i) {277 cbs[hooks[i]] = [];278 for (j = 0; j < modules.length; ++j) {279 if (modules[j][hooks[i]] !== undefined) cbs[hooks[i]].push(modules[j][hooks[i]]);280 }281 }282 function createElm(vnode) {283 var i;284 if (!isUndef(i = vnode.data) && !isUndef(i = i.hook) && !isUndef(i = i.init)) {285 i(vnode);286 }287 if (!isUndef(i = vnode.data) && !isUndef(i = i.vnode)) vnode = i;288 var elm,289 children = vnode.children,290 sel = vnode.sel;291 if (!isUndef(sel)) {292 // Parse selector293 var hashIdx = sel.indexOf('#');294 var dotIdx = sel.indexOf('.', hashIdx);295 var hash = hashIdx > 0 ? hashIdx : sel.length;296 var dot = dotIdx > 0 ? dotIdx : sel.length;297 var tag = hashIdx !== -1 || dotIdx !== -1 ? sel.slice(0, Math.min(hash, dot)) : sel;298 elm = vnode.elm = document.createElement(tag);299 if (hash < dot) elm.id = sel.slice(hash + 1, dot);300 if (dotIdx > 0) elm.className = sel.slice(dot + 1).replace(/\./g, ' ');301 if (is.array(children)) {302 for (i = 0; i < children.length; ++i) {303 elm.appendChild(createElm(children[i]));304 }305 } else if (is.primitive(vnode.text)) {306 elm.appendChild(document.createTextNode(vnode.text));307 }308 for (i = 0; i < cbs.create.length; ++i) cbs.create[i](emptyNode, vnode);309 i = vnode.data.hook; // Reuse variable310 if (!isUndef(i)) {311 if (i.create) i.create(vnode);312 if (i.insert) insertedVnodeQueue.push(vnode);313 }314 } else {315 elm = vnode.elm = document.createTextNode(vnode.text);316 }317 return elm;318 }319 function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {320 if (isUndef(before)) {321 for (; startIdx <= endIdx; ++startIdx) {322 parentElm.appendChild(createElm(vnodes[startIdx]));323 }324 } else {325 var elm = before.elm;326 for (; startIdx <= endIdx; ++startIdx) {327 parentElm.insertBefore(createElm(vnodes[startIdx]), elm);328 }329 }330 }331 function invokeDestroyHook(vnode) {332 var i = vnode.data.hook,333 j;334 if (!isUndef(i) && !isUndef(j = i.destroy)) j(vnode);335 for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode);336 if (!isUndef(vnode.children)) {337 for (j = 0; j < vnode.children.length; ++j) {338 invokeDestroyHook(vnode.children[j]);339 }340 }341 }342 function removeVnodes(parentElm, vnodes, startIdx, endIdx) {343 for (; startIdx <= endIdx; ++startIdx) {344 var i,345 listeners,346 rm,347 ch = vnodes[startIdx];348 if (!isUndef(ch)) {349 listeners = cbs.remove.length + 1;350 rm = createRmCb(parentElm, ch.elm, listeners);351 for (i = 0; i < cbs.remove.length; ++i) cbs.remove[i](ch, rm);352 invokeDestroyHook(ch);353 if (ch.data.hook && ch.data.hook.remove) {354 ch.data.hook.remove(ch, rm);355 } else {356 rm();357 }358 }359 }360 }361 function updateChildren(parentElm, oldCh, newCh) {362 var oldStartIdx = 0,363 newStartIdx = 0;364 var oldEndIdx = oldCh.length - 1;365 var oldStartVnode = oldCh[0];366 var oldEndVnode = oldCh[oldEndIdx];367 var newEndIdx = newCh.length - 1;368 var newStartVnode = newCh[0];369 var newEndVnode = newCh[newEndIdx];370 var oldKeyToIdx, idxInOld, elmToMove;371 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {372 if (isUndef(oldStartVnode)) {373 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left374 } else if (isUndef(oldEndVnode)) {375 oldEndVnode = oldCh[--oldEndIdx];376 } else if (sameVnode(oldStartVnode, newStartVnode)) {377 patchVnode(oldStartVnode, newStartVnode);378 oldStartVnode = oldCh[++oldStartIdx];379 newStartVnode = newCh[++newStartIdx];380 } else if (sameVnode(oldEndVnode, newEndVnode)) {381 patchVnode(oldEndVnode, newEndVnode);382 oldEndVnode = oldCh[--oldEndIdx];383 newEndVnode = newCh[--newEndIdx];384 } else if (sameVnode(oldStartVnode, newEndVnode)) {385 // Vnode moved right386 patchVnode(oldStartVnode, newEndVnode);387 parentElm.insertBefore(oldStartVnode.elm, oldEndVnode.elm.nextSibling);388 oldStartVnode = oldCh[++oldStartIdx];389 newEndVnode = newCh[--newEndIdx];390 } else if (sameVnode(oldEndVnode, newStartVnode)) {391 // Vnode moved left392 patchVnode(oldEndVnode, newStartVnode);393 parentElm.insertBefore(oldEndVnode.elm, oldStartVnode.elm);394 oldEndVnode = oldCh[--oldEndIdx];395 newStartVnode = newCh[++newStartIdx];396 } else {397 if (isUndef(oldKeyToIdx)) oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);398 idxInOld = oldKeyToIdx[newStartVnode.key];399 if (isUndef(idxInOld)) {400 // New element401 parentElm.insertBefore(createElm(newStartVnode), oldStartVnode.elm);402 newStartVnode = newCh[++newStartIdx];403 } else {404 elmToMove = oldCh[idxInOld];405 patchVnode(elmToMove, newStartVnode);406 oldCh[idxInOld] = undefined;407 parentElm.insertBefore(elmToMove.elm, oldStartVnode.elm);408 newStartVnode = newCh[++newStartIdx];409 }410 }411 }412 if (oldStartIdx > oldEndIdx) addVnodes(parentElm, oldStartVnode, newCh, newStartIdx, newEndIdx);else if (newStartIdx > newEndIdx) removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);413 }414 function patchVnode(oldVnode, vnode) {415 var i;416 if (!isUndef(i = vnode.data) && !isUndef(i = i.hook) && !isUndef(i = i.patch)) {417 i = i(oldVnode, vnode);418 }419 if (!isUndef(i = oldVnode.data) && !isUndef(i = i.vnode)) oldVnode = i;420 if (!isUndef(i = vnode.data) && !isUndef(i = i.vnode)) vnode = i;421 var elm = vnode.elm = oldVnode.elm,422 oldCh = oldVnode.children,423 ch = vnode.children;424 if (oldVnode === vnode) return;425 if (!isUndef(vnode.data)) {426 for (i = 0; i < cbs.update.length; ++i) cbs.update[i](oldVnode, vnode);427 i = vnode.data.hook;428 if (!isUndef(i) && !isUndef(i = i.update)) i(vnode);429 }430 if (isUndef(vnode.text)) {431 if (!isUndef(oldCh) && !isUndef(ch)) {432 if (oldCh !== ch) updateChildren(elm, oldCh, ch);433 } else if (!isUndef(ch)) {434 addVnodes(elm, undefined, ch, 0, ch.length - 1);435 } else if (!isUndef(oldCh)) {436 removeVnodes(elm, oldCh, 0, oldCh.length - 1);437 }438 } else if (oldVnode.text !== vnode.text) {439 elm.childNodes[0].nodeValue = vnode.text;440 }441 return vnode;442 }443 return function (oldVnode, vnode) {444 var i;445 insertedVnodeQueue = [];446 if (oldVnode instanceof Element) {447 oldVnode = emptyNodeAt(oldVnode);448 }449 for (i = 0; i < cbs.pre.length; ++i) cbs.pre[i]();...
util.js
Source:util.js
...12 * value(*): The value to check.13 * return(boolean): Returns true if value is undefined, else false.14 *15 * ```javascript16 * _.isUndef(void 0) // -> true17 * _.isUndef(null) // -> false18 * ```19 *20 * Just a shortcut for **x === undefined**, doesn't matter that much whether you21 * use it or not.22 */23 isUndef = function (value) { return value === void 0 };24 return isUndef;25 })();26 /* ------------------------------ _createAssigner ------------------------------ */27 var _createAssigner;28 _._createAssigner = (function ()29 {30 _createAssigner = function (keysFunc, defaults)31 {32 return function (obj)33 {34 var len = arguments.length;35 if (defaults) obj = Object(obj);36 if (len < 2 || obj == null) return obj;37 for (var i = 1; i < len; i++)38 {39 var src = arguments[i],40 keys = keysFunc(src),41 keysLen = keys.length;42 for (var j = 0; j < keysLen; j++)43 {44 var key = keys[j];45 if (!defaults || isUndef(obj[key])) obj[key] = src[key];46 }47 }48 return obj;49 };50 };51 return _createAssigner;52 })();53 /* ------------------------------ allKeys ------------------------------ */54 var allKeys;55 _.allKeys = (function ()56 {57 /* function58 * allKeys: Retrieve all the names of object's own and inherited properties.59 * object(object): The object to query....
class.js
Source:class.js
...12 const el = vnode.elm13 const data: VNodeData = vnode.data14 const oldData: VNodeData = oldVnode.data15 if (16 isUndef(data.staticClass) &&17 isUndef(data.class) && (18 isUndef(oldData) || (19 isUndef(oldData.staticClass) &&20 isUndef(oldData.class)21 )22 )23 ) {24 return25 }26 let cls = genClassForVnode(vnode)27 // handle transition classes28 const transitionClass = el._transitionClasses29 if (isDef(transitionClass)) {30 cls = concat(cls, stringifyClass(transitionClass))31 }32 // set the class33 if (cls !== el._prevClass) {34 el.setAttribute('class', cls)...
Using AI Code Generation
1const { isUndef } = require('playwright-core/lib/utils/utils');2const { isUndef } = require('playwright-core/lib/utils/utils');3const myVar = undefined;4if (isUndef(myVar)) {5 console.log('myVar is undefined');6} else {7 console.log('myVar is not undefined');8}9const { isUndef } = require('playwright-core/lib/utils/utils');10const timeout = 0;11if (isUndef(timeout)) {12 console.log('timeout is undefined');13} else {14 console.log('timeout is not undefined');15}
Using AI Code Generation
1const { isUndef } = require('playwright/lib/utils/utils');2const { isUndef } = require('playwright/lib/utils/utils');3const { isUndef } = require('playwright/lib/utils/utils');4const { isUndef } = require('playwright/lib/utils/utils');5const { isUndef } = require('playwright/lib/utils/utils');6const { isUndef } = require('playwright/lib/utils/utils');7const { isUndef } = require('playwright/lib/utils/utils');8const { isUndef } = require('playwright/lib/utils/utils');9const { isUndef } = require('playwright/lib/utils/utils');10const { isUndef } = require('playwright/lib/utils/utils');11const { isUndef } = require('playwright/lib/utils/utils');12const { isUndef } = require('playwright/lib/utils/utils');13const { isUndef } = require('playwright/lib/utils/utils');14const { isUndef } = require('playwright/lib/utils/utils');15const { isUndef } = require('playwright/lib/utils/utils');16const { isUndef } = require('playwright/lib/utils/utils');
Using AI Code Generation
1const { isUndef } = require('playwright-core/lib/utils/utils');2const { isUndef } = require('playwright');3const { isUndef } = require('playwright');4import { isUndef } from 'playwright';5const { isUndef } = require('playwright');6from playwright import is_undef7print(is_undef(None)) # False8print(is_undef(undefined)) # True9import com.microsoft.playwright.*;10public class MyTest {11 public static void main(String[] args) {12 }13}14using Microsoft.Playwright;15using System;16{17 {18 static void Main(string[] args)19 {20 }21 }22}23int main()24{25}
Using AI Code Generation
1const { isUndef } = require('playwright/lib/utils/utils');2if (isUndef(value)) {3}4const { isUndef } = require('playwright');5if (isUndef(value)) {6}7const { isUndef } = require('playwright/lib/utils/utils');8if (isUndef(value)) {9}10const { isUndef } = require('playwright');11if (isUndef(value)) {12}13const { isUndef } = require('playwright/lib/utils/utils');14if (isUndef(value)) {15}16const { isUndef } = require('playwright');17if (isUndef(value)) {18}19const { isUndef } = require('playwright/lib/utils/utils');20if (isUndef(value)) {21}22const { isUndef } = require('playwright');23if (isUndef(value)) {24}25const { isUndef } = require('playwright/lib/utils/utils');26if (isUndef(value)) {27}28const { isUndef } = require('playwright');29if (isUndef(value)) {30}31const { isUndef } = require('playwright/lib/utils/utils');32if (isUndef(value)) {33}
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!