How to use nextSibling method in Playwright Internal

Best JavaScript code snippet using playwright-internal

paralleltrees.js

Source:paralleltrees.js Github

copy

Full Screen

1/**2 * @license3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.4 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt6 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt7 * Code distributed by Google as part of the polymer project is also8 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt9 */10suite('Parallel Trees', function() {11 var wrap = ShadowDOMPolyfill.wrap;12 var unwrap = ShadowDOMPolyfill.unwrap;13 var visual = ShadowDOMPolyfill.visual;14 var NodeInvalidate = Node.prototype.invalidateShadowRenderer;15 setup(function() {16 Node.prototype.invalidateShadowRenderer = function() {17 return true;18 };19 });20 teardown(function() {21 Node.prototype.invalidateShadowRenderer = NodeInvalidate;22 });23 suite('Visual', function() {24 test('removeAllChildNodes wrapper', function() {25 var div = document.createElement('div');26 div.textContent = 'a';27 var textNode = div.firstChild;28 div.createShadowRoot();29 div.offsetWidth;30 expectStructure(unwrap(div), {});31 expectStructure(unwrap(textNode), {});32 expectStructure(div, {33 firstChild: textNode,34 lastChild: textNode35 });36 expectStructure(textNode, {37 parentNode: div38 });39 });40 test('removeAllChildNodes wrapper with 3 child nodes', function() {41 var div = document.createElement('div');42 div.innerHTML = '<a></a><b></b><c></c>';43 var a = div.firstChild;44 var b = a.nextSibling;45 var c = div.lastChild;46 div.createShadowRoot();47 div.offsetWidth;48 expectStructure(unwrap(div), {});49 expectStructure(unwrap(a), {});50 expectStructure(unwrap(b), {});51 expectStructure(unwrap(c), {});52 expectStructure(div, {53 firstChild: a,54 lastChild: c55 });56 expectStructure(a, {57 parentNode: div,58 nextSibling: b59 });60 expectStructure(b, {61 parentNode: div,62 previousSibling: a,63 nextSibling: c64 });65 expectStructure(c, {66 parentNode: div,67 previousSibling: b68 });69 });70 test('appendChild, start with no children', function() {71 var div = document.createElement('div');72 var textNode = document.createTextNode('hello');73 expectStructure(div, {});74 expectStructure(textNode, {});75 unwrapAndExpectStructure(div, {});76 unwrapAndExpectStructure(textNode, {});77 visual.insertBefore(div, textNode, null);78 unwrapAndExpectStructure(div, {79 firstChild: textNode,80 lastChild: textNode81 });82 unwrapAndExpectStructure(textNode, {83 parentNode: div84 });85 expectStructure(div, {});86 expectStructure(textNode, {});87 });88 test('appendChild, start with one child', function() {89 var div = document.createElement('div');90 div.innerHTML = '<a></a>';91 var a = div.firstChild;92 var b = document.createElement('b');93 visual.insertBefore(div, b, null);94 unwrapAndExpectStructure(div, {95 firstChild: a,96 lastChild: b97 });98 unwrapAndExpectStructure(a, {99 parentNode: div,100 nextSibling: b101 });102 unwrapAndExpectStructure(b, {103 parentNode: div,104 previousSibling: a105 });106 expectStructure(div, {107 firstChild: a,108 lastChild: a109 });110 expectStructure(a, {111 parentNode: div112 });113 expectStructure(b, {});114 });115 test('appendChild, start with two children', function() {116 var div = document.createElement('div');117 div.innerHTML = '<a></a><b></b>';118 var a = div.firstChild;119 var b = div.lastChild;120 var c = document.createElement('c');121 visual.insertBefore(div, c, null);122 unwrapAndExpectStructure(div, {123 firstChild: a,124 lastChild: c125 });126 unwrapAndExpectStructure(a, {127 parentNode: div,128 nextSibling: b129 });130 unwrapAndExpectStructure(b, {131 parentNode: div,132 previousSibling: a,133 nextSibling: c134 });135 unwrapAndExpectStructure(c, {136 parentNode: div,137 previousSibling: b138 });139 expectStructure(div, {140 firstChild: a,141 lastChild: b142 });143 expectStructure(a, {144 parentNode: div,145 nextSibling: b146 });147 expectStructure(b, {148 parentNode: div,149 previousSibling: a150 });151 expectStructure(c, {});152 });153 test('appendChild with document fragment again', function() {154 var div = document.createElement('div');155 div.innerHTML = '<a></a>';156 var a = div.lastChild;157 var df = document.createDocumentFragment();158 var b = df.appendChild(document.createElement('b'));159 var c = df.appendChild(document.createElement('c'));160 div.appendChild(df);161 expectStructure(df, {});162 expectStructure(div, {163 firstChild: a,164 lastChild: c165 });166 expectStructure(a, {167 parentNode: div,168 nextSibling: b169 });170 expectStructure(b, {171 parentNode: div,172 previousSibling: a,173 nextSibling: c174 });175 expectStructure(c, {176 parentNode: div,177 previousSibling: b178 });179 unwrapAndExpectStructure(df, {});180 unwrapAndExpectStructure(div, {181 firstChild: a,182 lastChild: c183 });184 unwrapAndExpectStructure(a, {185 parentNode: div,186 nextSibling: b187 });188 unwrapAndExpectStructure(b, {189 parentNode: div,190 previousSibling: a,191 nextSibling: c192 });193 unwrapAndExpectStructure(c, {194 parentNode: div,195 previousSibling: b196 });197 });198 test('appendChild with empty document fragment', function() {199 var div = document.createElement('div');200 div.innerHTML = '<a></a>';201 var a = div.lastChild;202 var df = document.createDocumentFragment();203 div.appendChild(df);204 expectStructure(df, {});205 expectStructure(div, {206 firstChild: a,207 lastChild: a208 });209 expectStructure(a, {210 parentNode: div211 });212 unwrapAndExpectStructure(df, {});213 unwrapAndExpectStructure(div, {214 firstChild: a,215 lastChild: a216 });217 unwrapAndExpectStructure(a, {218 parentNode: div219 });220 });221 test('insertBefore', function() {222 var a = document.createElement('a');223 var b = document.createElement('b');224 a.appendChild(b);225 unwrapAndExpectStructure(a, {226 firstChild: b,227 lastChild: b228 });229 unwrapAndExpectStructure(b, {230 parentNode: a231 });232 expectStructure(a, {233 firstChild: b,234 lastChild: b235 });236 expectStructure(b, {237 parentNode: a238 });239 var c = document.createElement('c');240 visual.insertBefore(a, c, b);241 unwrapAndExpectStructure(a, {242 firstChild: c,243 lastChild: b244 });245 unwrapAndExpectStructure(b, {246 parentNode: a,247 previousSibling: c248 });249 unwrapAndExpectStructure(c, {250 parentNode: a,251 nextSibling: b252 });253 expectStructure(a, {254 firstChild: b,255 lastChild: b256 });257 expectStructure(b, {258 parentNode: a259 });260 expectStructure(c, {});261 var d = document.createElement('d');262 visual.insertBefore(a, d, b);263 unwrapAndExpectStructure(a, {264 firstChild: c,265 lastChild: b266 });267 unwrapAndExpectStructure(b, {268 parentNode: a,269 previousSibling: d270 });271 unwrapAndExpectStructure(c, {272 parentNode: a,273 nextSibling: d274 });275 unwrapAndExpectStructure(d, {276 parentNode: a,277 nextSibling: b,278 previousSibling: c279 });280 expectStructure(a, {281 firstChild: b,282 lastChild: b283 });284 expectStructure(b, {285 parentNode: a286 });287 expectStructure(c, {});288 expectStructure(d, {});289 });290 test('insertBefore 2', function() {291 var a = document.createElement('a');292 var b = document.createElement('b');293 var c = document.createElement('b');294 a.appendChild(b);295 a.appendChild(c);296 unwrapAndExpectStructure(a, {297 firstChild: b,298 lastChild: c299 });300 unwrapAndExpectStructure(b, {301 parentNode: a,302 nextSibling: c303 });304 unwrapAndExpectStructure(c, {305 parentNode: a,306 previousSibling: b307 });308 expectStructure(a, {309 firstChild: b,310 lastChild: c311 });312 expectStructure(b, {313 parentNode: a,314 nextSibling: c315 });316 expectStructure(c, {317 parentNode: a,318 previousSibling: b319 });320 // b d c321 var d = document.createElement('d');322 visual.insertBefore(a, d, c);323 unwrapAndExpectStructure(a, {324 firstChild: b,325 lastChild: c326 });327 unwrapAndExpectStructure(b, {328 parentNode: a,329 nextSibling: d330 });331 unwrapAndExpectStructure(c, {332 parentNode: a,333 previousSibling: d334 });335 unwrapAndExpectStructure(d, {336 parentNode: a,337 previousSibling: b,338 nextSibling: c339 });340 expectStructure(a, {341 firstChild: b,342 lastChild: c343 });344 expectStructure(b, {345 parentNode: a,346 nextSibling: c347 });348 expectStructure(c, {349 parentNode: a,350 previousSibling: b351 });352 expectStructure(d, {});353 });354 test('removeChild, start with one child', function() {355 var div = document.createElement('div');356 div.innerHTML = '<a></a>';357 var a = div.firstChild;358 visual.remove(a);359 unwrapAndExpectStructure(div, {});360 unwrapAndExpectStructure(a, {});361 expectStructure(div, {362 firstChild: a,363 lastChild: a364 });365 expectStructure(a, {366 parentNode: div367 });368 });369 test('removeChild, start with two children, remove first', function() {370 var div = document.createElement('div');371 div.innerHTML = '<a></a><b></b>';372 var a = div.firstChild;373 var b = div.lastChild;374 visual.remove(a);375 unwrapAndExpectStructure(div, {376 firstChild: b,377 lastChild: b378 });379 unwrapAndExpectStructure(a, {});380 unwrapAndExpectStructure(b, {381 parentNode: div382 });383 expectStructure(div, {384 firstChild: a,385 lastChild: b386 });387 expectStructure(a, {388 parentNode: div,389 nextSibling: b390 });391 expectStructure(b, {392 parentNode: div,393 previousSibling: a394 });395 });396 test('removeChild, start with two children, remove last', function() {397 var div = document.createElement('div');398 div.innerHTML = '<a></a><b></b>';399 var a = div.firstChild;400 var b = div.lastChild;401 visual.remove(b);402 unwrapAndExpectStructure(div, {403 firstChild: a,404 lastChild: a405 });406 unwrapAndExpectStructure(a, {407 parentNode: div408 });409 unwrapAndExpectStructure(b, {});410 expectStructure(div, {411 firstChild: a,412 lastChild: b413 });414 expectStructure(a, {415 parentNode: div,416 nextSibling: b417 });418 expectStructure(b, {419 parentNode: div,420 previousSibling: a421 });422 });423 test('removeChild, start with three children, remove middle', function() {424 var div = document.createElement('div');425 div.innerHTML = '<a></a><b></b><c></c>';426 var a = div.firstChild;427 var b = a.nextSibling;428 var c = div.lastChild;429 visual.remove(b);430 unwrapAndExpectStructure(div, {431 firstChild: a,432 lastChild: c433 });434 unwrapAndExpectStructure(a, {435 parentNode: div,436 nextSibling: c437 });438 unwrapAndExpectStructure(b, {});439 unwrapAndExpectStructure(c, {440 parentNode: div,441 previousSibling: a442 });443 expectStructure(div, {444 firstChild: a,445 lastChild: c446 });447 expectStructure(a, {448 parentNode: div,449 nextSibling: b450 });451 expectStructure(b, {452 parentNode: div,453 previousSibling: a,454 nextSibling: c455 });456 expectStructure(c, {457 parentNode: div,458 previousSibling: b459 });460 });461 });462 suite('Logical', function() {463 suite('removeAllChildNodes', function() {464 test('simple', function() {465 var div = document.createElement('div');466 div.innerHTML = '<a></a><b></b><c></c>';467 var a = div.firstChild;468 var b = a.nextSibling;469 var c = div.lastChild;470 div.textContent = '';471 unwrapAndExpectStructure(div, {});472 unwrapAndExpectStructure(a, {});473 unwrapAndExpectStructure(b, {});474 unwrapAndExpectStructure(c, {});475 expectStructure(div, {});476 expectStructure(a, {});477 expectStructure(b, {});478 expectStructure(c, {});479 });480 test('with wrappers before removal', function() {481 var div = document.createElement('div');482 div.innerHTML = '<a></a><b></b><c></c>';483 var a = div.firstChild;484 var b = a.nextSibling;485 var c = div.lastChild;486 div.textContent = '';487 unwrapAndExpectStructure(div, {});488 unwrapAndExpectStructure(a, {});489 unwrapAndExpectStructure(b, {});490 unwrapAndExpectStructure(c, {});491 expectStructure(div, {});492 expectStructure(a, {});493 expectStructure(b, {});494 expectStructure(c, {});495 });496 test('change visual first', function() {497 var div = document.createElement('div');498 div.innerHTML = '<a></a><b></b><c></c>';499 var a = div.firstChild;500 var b = a.nextSibling;501 var c = div.lastChild;502 div.createShadowRoot();503 div.offsetWidth;504 unwrapAndExpectStructure(div, {});505 unwrapAndExpectStructure(a, {});506 unwrapAndExpectStructure(b, {});507 unwrapAndExpectStructure(c, {});508 div.textContent = '';509 expectStructure(div, {});510 expectStructure(a, {});511 expectStructure(b, {});512 expectStructure(c, {});513 });514 });515 suite('appendChild', function() {516 test('simple', function() {517 var div = document.createElement('div');518 div.innerHTML = '<a></a><b></b>';519 var a = div.firstChild;520 var b = a.nextSibling;521 var c = document.createElement('c');522 div.appendChild(c);523 unwrapAndExpectStructure(div, {524 firstChild: a,525 lastChild: c526 });527 unwrapAndExpectStructure(a, {528 parentNode: div,529 nextSibling: b530 });531 unwrapAndExpectStructure(b, {532 parentNode: div,533 previousSibling: a,534 nextSibling: c535 });536 unwrapAndExpectStructure(c, {537 parentNode: div,538 previousSibling: b539 });540 expectStructure(div, {541 firstChild: a,542 lastChild: c543 });544 expectStructure(a, {545 parentNode: div,546 nextSibling: b547 });548 expectStructure(b, {549 parentNode: div,550 previousSibling: a,551 nextSibling: c552 });553 expectStructure(c, {554 parentNode: div,555 previousSibling: b556 });557 });558 test('with wrappers before', function() {559 var div = document.createElement('div');560 div.innerHTML = '<a></a><b></b>';561 var a = div.firstChild;562 var b = a.nextSibling;563 var c = document.createElement('c');564 div.appendChild(c);565 unwrapAndExpectStructure(div, {566 firstChild: a,567 lastChild: c568 });569 unwrapAndExpectStructure(a, {570 parentNode: div,571 nextSibling: b572 });573 unwrapAndExpectStructure(b, {574 parentNode: div,575 previousSibling: a,576 nextSibling: c577 });578 unwrapAndExpectStructure(c, {579 parentNode: div,580 previousSibling: b581 });582 expectStructure(div, {583 firstChild: a,584 lastChild: c585 });586 expectStructure(a, {587 parentNode: div,588 nextSibling: b589 });590 expectStructure(b, {591 parentNode: div,592 previousSibling: a,593 nextSibling: c594 });595 expectStructure(c, {596 parentNode: div,597 previousSibling: b598 });599 });600 test('change visual first', function() {601 var div = document.createElement('div');602 div.innerHTML = '<a></a><b></b>';603 var a = div.firstChild;604 var b = a.nextSibling;605 var c = document.createElement('c');606 div.createShadowRoot();607 div.offsetWidth;608 div.appendChild(c);609 unwrapAndExpectStructure(div, {610 firstChild: c,611 lastChild: c612 });613 unwrapAndExpectStructure(a, {});614 unwrapAndExpectStructure(b, {});615 unwrapAndExpectStructure(c, {616 parentNode: div617 });618 expectStructure(div, {619 firstChild: a,620 lastChild: c621 });622 expectStructure(a, {623 parentNode: div,624 nextSibling: b625 });626 expectStructure(b, {627 parentNode: div,628 previousSibling: a,629 nextSibling: c630 });631 expectStructure(c, {632 parentNode: div,633 previousSibling: b634 });635 });636 });637 suite('insertBefore', function() {638 test('simple', function() {639 var div = document.createElement('div');640 div.innerHTML = '<a></a><c></c>';641 var a = div.firstChild;642 var c = a.nextSibling;643 var b = document.createElement('b');644 div.insertBefore(b, c);645 unwrapAndExpectStructure(div, {646 firstChild: a,647 lastChild: c648 });649 unwrapAndExpectStructure(a, {650 parentNode: div,651 nextSibling: b652 });653 unwrapAndExpectStructure(b, {654 parentNode: div,655 previousSibling: a,656 nextSibling: c657 });658 unwrapAndExpectStructure(c, {659 parentNode: div,660 previousSibling: b661 });662 expectStructure(div, {663 firstChild: a,664 lastChild: c665 });666 expectStructure(a, {667 parentNode: div,668 nextSibling: b669 });670 expectStructure(b, {671 parentNode: div,672 previousSibling: a,673 nextSibling: c674 });675 expectStructure(c, {676 parentNode: div,677 previousSibling: b678 });679 });680 test('with wrappers before', function() {681 var div = document.createElement('div');682 div.innerHTML = '<a></a><c></c>';683 var a = div.firstChild;684 var c = a.nextSibling;685 var b = document.createElement('b');686 div.insertBefore(b, c);687 unwrapAndExpectStructure(div, {688 firstChild: a,689 lastChild: c690 });691 unwrapAndExpectStructure(a, {692 parentNode: div,693 nextSibling: b694 });695 unwrapAndExpectStructure(b, {696 parentNode: div,697 previousSibling: a,698 nextSibling: c699 });700 unwrapAndExpectStructure(c, {701 parentNode: div,702 previousSibling: b703 });704 expectStructure(div, {705 firstChild: a,706 lastChild: c707 });708 expectStructure(a, {709 parentNode: div,710 nextSibling: b711 });712 expectStructure(b, {713 parentNode: div,714 previousSibling: a,715 nextSibling: c716 });717 expectStructure(c, {718 parentNode: div,719 previousSibling: b720 });721 });722 test('change visual first', function() {723 var div = document.createElement('div');724 div.innerHTML = '<a></a><c></c>';725 var a = div.firstChild;726 var c = a.nextSibling;727 var b = document.createElement('b');728 div.createShadowRoot();729 div.offsetWidth;730 div.insertBefore(b, c);731 unwrapAndExpectStructure(div, {});732 unwrapAndExpectStructure(a, {});733 unwrapAndExpectStructure(b, {});734 unwrapAndExpectStructure(c, {});735 expectStructure(div, {736 firstChild: a,737 lastChild: c738 });739 expectStructure(a, {740 parentNode: div,741 nextSibling: b742 });743 expectStructure(b, {744 parentNode: div,745 previousSibling: a,746 nextSibling: c747 });748 expectStructure(c, {749 parentNode: div,750 previousSibling: b751 });752 // swap a and b753 div.insertBefore(b, a);754 expectStructure(div, {755 firstChild: b,756 lastChild: c757 });758 expectStructure(b, {759 parentNode: div,760 nextSibling: a761 });762 expectStructure(a, {763 parentNode: div,764 previousSibling: b,765 nextSibling: c766 });767 expectStructure(c, {768 parentNode: div,769 previousSibling: a770 });771 // swap a and c772 div.insertBefore(c, a);773 expectStructure(div, {774 firstChild: b,775 lastChild: a776 });777 expectStructure(b, {778 parentNode: div,779 nextSibling: c780 });781 expectStructure(c, {782 parentNode: div,783 previousSibling: b,784 nextSibling: a785 });786 expectStructure(a, {787 parentNode: div,788 previousSibling: c789 });790 });791 });792 test('insertBefore with document fragment', function() {793 var div = document.createElement('div');794 var c = div.appendChild(document.createElement('c'));795 var df = document.createDocumentFragment();796 var a = df.appendChild(document.createElement('a'));797 var b = df.appendChild(document.createElement('b'));798 div.createShadowRoot();799 div.offsetWidth;800 div.insertBefore(df, c);801 unwrapAndExpectStructure(div, {});802 unwrapAndExpectStructure(df, {});803 unwrapAndExpectStructure(a, {});804 unwrapAndExpectStructure(b, {});805 unwrapAndExpectStructure(c, {});806 expectStructure(div, {807 firstChild: a,808 lastChild: c809 });810 expectStructure(df, {});811 expectStructure(a, {812 parentNode: div,813 nextSibling: b814 });815 expectStructure(b, {816 parentNode: div,817 previousSibling: a,818 nextSibling: c819 });820 expectStructure(c, {821 parentNode: div,822 previousSibling: b823 });824 });825 test('insertBefore with document fragment again', function() {826 var div = document.createElement('div');827 div.innerHTML = '<a></a><d></d>';828 var a = div.firstChild;829 var d = div.lastChild;830 var df = document.createDocumentFragment();831 var b = df.appendChild(document.createElement('b'));832 var c = df.appendChild(document.createElement('c'));833 div.insertBefore(df, d);834 expectStructure(df, {});835 expectStructure(div, {836 firstChild: a,837 lastChild: d838 });839 expectStructure(a, {840 parentNode: div,841 nextSibling: b842 });843 expectStructure(b, {844 parentNode: div,845 previousSibling: a,846 nextSibling: c847 });848 expectStructure(c, {849 parentNode: div,850 previousSibling: b,851 nextSibling: d852 });853 expectStructure(d, {854 parentNode: div,855 previousSibling: c856 });857 unwrapAndExpectStructure(df, {});858 unwrapAndExpectStructure(div, {859 firstChild: a,860 lastChild: d861 });862 unwrapAndExpectStructure(a, {863 parentNode: div,864 nextSibling: b865 });866 unwrapAndExpectStructure(b, {867 parentNode: div,868 previousSibling: a,869 nextSibling: c870 });871 unwrapAndExpectStructure(c, {872 parentNode: div,873 previousSibling: b,874 nextSibling: d875 });876 unwrapAndExpectStructure(d, {877 parentNode: div,878 previousSibling: c879 });880 });881 test('insertBefore with different documents', function() {882 var doc = document.implementation.createHTMLDocument('');883 var div = doc.createElement('div');884 div.innerHTML = '<a></a><b></b>';885 var a = div.firstChild;886 var b = div.lastChild;887 div.createShadowRoot();888 div.offsetWidth;889 expectStructure(div, {890 firstChild: a,891 lastChild: b892 });893 expectStructure(a, {894 parentNode: div,895 nextSibling: b896 });897 expectStructure(b, {898 parentNode: div,899 previousSibling: a900 });901 var c = document.createElement('c');902 div.insertBefore(c, b);903 expectStructure(div, {904 firstChild: a,905 lastChild: b906 });907 expectStructure(a, {908 parentNode: div,909 nextSibling: c910 });911 expectStructure(b, {912 parentNode: div,913 previousSibling: c914 });915 expectStructure(c, {916 parentNode: div,917 previousSibling: a,918 nextSibling: b,919 });920 assert.equal(div.ownerDocument, doc);921 assert.equal(a.ownerDocument, div.ownerDocument);922 assert.equal(b.ownerDocument, div.ownerDocument);923 assert.equal(c.ownerDocument, div.ownerDocument);924 });925 suite('replaceChild', function() {926 test('simple', function() {927 var div = document.createElement('div');928 div.innerHTML = '<a></a><c></c>';929 var a = div.firstChild;930 var c = a.nextSibling;931 var b = document.createElement('b');932 div.replaceChild(b, c);933 unwrapAndExpectStructure(div, {934 firstChild: a,935 lastChild: b936 });937 unwrapAndExpectStructure(a, {938 parentNode: div,939 nextSibling: b940 });941 unwrapAndExpectStructure(b, {942 parentNode: div,943 previousSibling: a944 });945 unwrapAndExpectStructure(c, {});946 expectStructure(div, {947 firstChild: a,948 lastChild: b949 });950 expectStructure(a, {951 parentNode: div,952 nextSibling: b953 });954 expectStructure(b, {955 parentNode: div,956 previousSibling: a957 });958 expectStructure(c, {});959 });960 test('with wrappers before', function() {961 var div = document.createElement('div');962 div.innerHTML = '<a></a><c></c>';963 var a = div.firstChild;964 var c = a.nextSibling;965 var b = document.createElement('b');966 div.replaceChild(b, c);967 expectStructure(div, {968 firstChild: a,969 lastChild: b970 });971 expectStructure(a, {972 parentNode: div,973 nextSibling: b974 });975 expectStructure(b, {976 parentNode: div,977 previousSibling: a978 });979 expectStructure(c, {});980 expectStructure(div, {981 firstChild: a,982 lastChild: b983 });984 expectStructure(a, {985 parentNode: div,986 nextSibling: b987 });988 expectStructure(b, {989 parentNode: div,990 previousSibling: a991 });992 expectStructure(c, {});993 });994 test('change visual first', function() {995 var div = document.createElement('div');996 div.innerHTML = '<a></a><c></c>';997 var a = div.firstChild;998 var c = a.nextSibling;999 var b = document.createElement('b');1000 div.createShadowRoot();1001 div.offsetWidth;1002 div.replaceChild(b, c);1003 unwrapAndExpectStructure(div, {});1004 unwrapAndExpectStructure(a, {});1005 unwrapAndExpectStructure(b, {});1006 unwrapAndExpectStructure(c, {});1007 expectStructure(div, {1008 firstChild: a,1009 lastChild: b1010 });1011 expectStructure(a, {1012 parentNode: div,1013 nextSibling: b1014 });1015 expectStructure(b, {1016 parentNode: div,1017 previousSibling: a1018 });1019 expectStructure(c, {});1020 // Remove a1021 div.replaceChild(b, a);1022 expectStructure(div, {1023 firstChild: b,1024 lastChild: b1025 });1026 expectStructure(a, {});1027 expectStructure(b, {1028 parentNode: div1029 });1030 expectStructure(c, {});1031 // Swap b with c1032 div.replaceChild(c, b);1033 expectStructure(div, {1034 firstChild: c,1035 lastChild: c1036 });1037 expectStructure(a, {});1038 expectStructure(b, {});1039 expectStructure(c, {1040 parentNode: div1041 });1042 });1043 test('replaceChild with document fragment', function() {1044 var div = document.createElement('div');1045 div.innerHTML = '<a></a><e></e><d></d>';1046 var a = div.firstChild;1047 var e = a.nextSibling;1048 var d = e.nextSibling;1049 var df = document.createDocumentFragment();1050 var b = df.appendChild(document.createElement('b'));1051 var c = df.appendChild(document.createElement('c'));1052 div.replaceChild(df, e);1053 expectStructure(df, {});1054 expectStructure(e, {});1055 expectStructure(div, {1056 firstChild: a,1057 lastChild: d1058 });1059 expectStructure(a, {1060 parentNode: div,1061 nextSibling: b1062 });1063 expectStructure(b, {1064 parentNode: div,1065 previousSibling: a,1066 nextSibling: c1067 });1068 expectStructure(c, {1069 parentNode: div,1070 previousSibling: b,1071 nextSibling: d1072 });1073 expectStructure(d, {1074 parentNode: div,1075 previousSibling: c1076 });1077 unwrapAndExpectStructure(df, {});1078 unwrapAndExpectStructure(e, {});1079 unwrapAndExpectStructure(div, {1080 firstChild: a,1081 lastChild: d1082 });1083 unwrapAndExpectStructure(a, {1084 parentNode: div,1085 nextSibling: b1086 });1087 unwrapAndExpectStructure(b, {1088 parentNode: div,1089 previousSibling: a,1090 nextSibling: c1091 });1092 unwrapAndExpectStructure(c, {1093 parentNode: div,1094 previousSibling: b,1095 nextSibling: d1096 });1097 unwrapAndExpectStructure(d, {1098 parentNode: div,1099 previousSibling: c1100 });1101 });1102 });1103 });1104 test('innerHTML', function() {1105 var doc = wrap(document);1106 var div = doc.createElement('div');1107 div.innerHTML = '<a></a>';1108 div.createShadowRoot();1109 div.offsetWidth;1110 var a = div.firstChild;1111 div.innerHTML = '<b></b>';1112 assert.equal(div.firstChild.tagName, 'B');1113 });...

Full Screen

Full Screen

Admins.js

Source:Admins.js Github

copy

Full Screen

1layui.use('layer', function () {2 var layer = layui.layer;3});4//关闭5function guanbi() {6 var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引7 parent.layer.close(index); //再执行关闭8}9//新增培训计划10function xiadan() {11 layer.open({12 anim: 1,13 type: 2,14 title: '立即下单',15 shadeClose: true,16 shade: false,17 maxmin: true,18 id: 'xiadan',19 area: ['450', '600'],20 content: ['/jsp/xiadan.jsp'],21 // end: function () {22 // $("#searchUserifAccount").click();23 // }24 });25}26//新增培训计划27function add() {28 layer.open({29 anim: 1,30 type: 2,31 title: '新增培训计划',32 shadeClose: true,33 shade: false,34 maxmin: true,35 id: 'addTrain',36 area: ['450', '600'],37 content: ['/jsp/Admin_Trainadd.jsp'],38 end: function () {39 $("#searchUserifAccount").click();40 }41 });42}43//新增培训计划ajax44function addTrain(node) {45 var path = $("#path").val();46 var title = $("#title").val();47 var startDate = $("#startDate").val();48 var endDate = $("#endDate").val();49 var startTime = $("#startTime").val();50 var endTime = $("#endTime").val();51 var content = $("#content").val();52 var count = $("#count").val();53 var length = $("#length").val();54 $.ajax({55 url:path+"/adminTrain/addTrain",56 data: {title: title, startDate: startDate, endDate: endDate,startTime: startTime, endTime: endTime, content: content, count: count,length: length},57 success: function (data) {58 if (data == "添加成功") {59 alert("添加成功");60 guanbi();61 } else {62 layer.alert("添加失败")63 }64 },65 end: function () {66 $("#searchUserifAccount").click();67 }68 })69}70//修改培训计划71function update(node) {72 var title = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;73 var startDate = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;74 var endDate = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;75 var startTime = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.textContent;76 var endTime = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;77 var content = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;78 var count = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;79 var length = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;80 var id = $(node).parent("div").parent("td").parent("tr")[0].firstChild.textContent;81 layer.open({82 anim: 1,83 type: 2,84 title: '修改',85 shadeClose: true,86 shade: false,87 maxmin: true,88 id: 'updateTrain',89 area: ['450', '600'],90 content: ['/jsp/Admin_Trainupdate.jsp'],91 success: function (layero, index) {92 var body = layer.getChildFrame('body', index);93 body.contents().find("#title").val(title);94 body.contents().find("#startDate").val(startDate);95 body.contents().find("#endDate").val(endDate);96 body.contents().find("#startTime").val(startTime);97 body.contents().find("#endTime").val(endTime);98 body.contents().find("#content").val(content);99 body.contents().find("#count").val(count);100 body.contents().find("#length").val(length);101 body.contents().find("#id").val(id);102 },103 end: function () {104 $("#searchUserifAccount").click();105 }106 });107}108//修改培训计划ajax109function updateTrain(node) {110 var title = $("#title").val();111 var startDate = $("#startDate").val();112 var endDate = $("#endDate").val();113 var startTime = $("#startTime").val();114 var endTime = $("#endTime").val();115 var content = $("#content").val();116 var count = $("#count").val();117 var length = $("#length").val();118 var id = $("#id").val();119 var path = $("#path").val();120 $.ajax({121 url:path+"/adminTrain/updateTrain",122 data: {title: title, startDate: startDate,123 endDate: endDate,startTime: startTime, endTime: endTime, content: content,124 count: count, length: length, id: id},125 success: function (data) {126 if (data == "修改成功") {127 alert("修改成功");128 guanbi();129 } else {130 layer.alert("修改失败")131 }132 },133 end: function () {134 $("#searchUserifAccount").click();135 }136 })137}138//家政公司列表查看详情139function look(node) {140 var name = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;141 var legal = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;142 var address = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;143 var phone = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.textContent;144 var stateName = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;145 var areaName = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;146 var entryDate = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;147 var account = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;148 var money = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;149 var id = $(node).parent("div").parent("td").parent("tr")[0].firstChild.textContent;150 layer.open({151 anim: 1,152 type: 2,153 title: '查看详情',154 shadeClose: true,155 shade: false,156 maxmin: true,157 id: 'look',158 area: ['400', '500'],159 content: ['/jsp/Admin_Companylook.jsp'],160 success: function (layero, index) {161 var body = layer.getChildFrame('body', index);162 body.contents().find("#name").val(name);163 body.contents().find("#legal").val(legal);164 body.contents().find("#address").val(address);165 body.contents().find("#phone").val(phone);166 body.contents().find("#stateName").val(stateName);167 body.contents().find("#areaName").val(areaName);168 body.contents().find("#entryDate").val(entryDate);169 body.contents().find("#account").val(account);170 body.contents().find("#money").val(money);171 body.contents().find("#id").val(id);172 },173 end: function () {174 $("#searchUserifAccount").click();175 }176 });177}178//发布动态公告179function fabu() {180 layer.open({181 anim: 1,182 type: 2,183 title: '发布公告',184 shadeClose: true,185 shade: false,186 maxmin: true,187 id: 'fabus',188 area: ['450', '400'],189 content: ['/jsp/Admin_Afficheadd.jsp'],190 end: function () {191 $("#searchUserifAccount").click();192 }193 });194}195//发布动态公告ajax196function fabus(node) {197 var title = $("#title").val();198 var describes = $("#describes").val();199 var releasrDate = $("#releasrDate").val();200 var path = $("#path").val();201 $.ajax({202 url: path+"/adminAffiche/addTAffiche",203 data: {title: title, describes: describes,releasrDate:releasrDate},204 success: function (data) {205 if (data == "发布成功") {206 alert("发布成功");207 guanbi();208 } else {209 layer.alert("发布失败")210 }211 },212 end: function () {213 $("#searchUserifAccount").click();214 }215 })216}217//动态公告查看218function lookAffiche(node) {219 var releasrDate = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;220 var describes = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;221 var title = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;222 layer.open({223 anim: 1,224 type: 2,225 title: '查看详情',226 shadeClose: true,227 shade: false,228 maxmin: true,229 id: 'lookAffiche',230 area: ['400', '500'],231 content: ['/jsp/Admin_Affichelook.jsp'],232 success: function (layero, index) {233 var body = layer.getChildFrame('body', index);234 body.contents().find("#releasrDate").val(releasrDate);235 body.contents().find("#describes").val(describes);236 body.contents().find("#title").val(title);237 },238 end: function () {239 $("#searchUserifAccount").click();240 }241 });242}243function updateAffiche(node) {244 var releasrDate = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;245 var describes = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;246 var title = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;247 var id = $(node).parent("div").parent("td").parent("tr")[0].firstChild.textContent;248 layer.open({249 anim: 1,250 type: 2,251 title: '修改公告信息',252 shadeClose: true,253 shade: false,254 maxmin: true,255 id: 'update',256 area: ['400', '500'],257 content: ['/jsp/Admin_Afficheupdate.jsp'],258 success: function (layero, index) {259 var body = layer.getChildFrame('body', index);260 body.contents().find("#releasrDate").val(releasrDate);261 body.contents().find("#describes").val(describes);262 body.contents().find("#title").val(title);263 body.contents().find("#id").val(id);264 },265 end: function () {266 $("#searchUserifAccount").click();267 }268 });269}270function updateAffiches(node) {271 var title = $("#title").val();272 // var releasrDate = $("#releasrDate").val();273 var describes = $("#describes").val();274 var id = $("#id").val();275 var path = $("#path").val();276 $.ajax({277 url: path+"/adminAffiche/updateAffiche",278 data: {title: title,279 describes: describes,id: id},280 success: function (data) {281 if (data == "修改成功") {282 alert("修改成功");283 guanbi();284 } else {285 layer.alert("修改失败")286 }287 },288 end: function () {289 $("#searchUserifAccount").click();290 }291 })292}293//查看服务类型294function lookType(node) {295 var typeName = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;296 var name = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;297 var id1 = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;298 var id = $(node).parent("div").parent("td").parent("tr")[0].firstChild.textContent;299 layer.open({300 anim: 1,301 type: 2,302 title: '查看详情',303 shadeClose: true,304 shade: false,305 maxmin: true,306 id: 'lookType',307 area: ['400', '400'],308 content: ['/jsp/Admin_ServerTypelook.jsp'],309 success: function (layero, index) {310 var body = layer.getChildFrame('body', index);311 body.contents().find("#id").val(id);312 body.contents().find("#id1").val(id1);313 body.contents().find("#name").val(name);314 body.contents().find("#typeName").val(typeName);315 },316 end: function () {317 $("#searchUserifAccount").click();318 }319 });320}321//修改服务类型322function updatesType(node) {323 var typeName = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;324 var name = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;325 var id1 = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;326 // var pid1 = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.textContent;327 var id = $(node).parent("div").parent("td").parent("tr")[0].firstChild.textContent;328 layer.open({329 anim: 1,330 type: 2,331 title: '修改服务类型',332 shadeClose: true,333 shade: false,334 maxmin: true,335 id: 'updatesTypes',336 area: ['400', '400'],337 content: ['/jsp/Admin_ServerTypeupdate.jsp'],338 success: function (layero, index) {339 var body = layer.getChildFrame('body', index);340 body.contents().find("#typeName").val(typeName);341 body.contents().find("#name").val(name);342 body.contents().find("#id1").val(id1);343 body.contents().find("#id").val(id);344 },345 end: function () {346 $("#searchUserifAccount").click();347 }348 });349}350function updatesTypes(node) {351 var typeName = $("#typeName").val();352 var id = $("#id").val();353 var name = $("#name").val();354 var id1 = $("#id1").val();355 var path = $("#path").val();356 $.ajax({357 url:path+"/adminType/updatesType",358 data: {typeName: typeName,id: id,359 name: name,id1: id1},360 success: function (data) {361 if (data == "修改成功") {362 alert("修改成功");363 guanbi();364 } else {365 layer.alert("修改失败")366 }367 },368 end: function () {369 $("#searchUserifAccount").click();370 }371 })372}373//修改服务374function updateServer(node) {375 var typeName = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;376 var name = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;377 var id1 = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;378 var pid1 = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.textContent;379 var id = $(node).parent("div").parent("td").parent("tr")[0].firstChild.textContent;380 layer.open({381 anim: 1,382 type: 2,383 title: '修改服务',384 shadeClose: true,385 shade: false,386 maxmin: true,387 id: 'updateServers',388 area: ['400', '400'],389 content: ['/jsp/Admin_ServerTypeupdates.jsp'],390 success: function (layero, index) {391 var body = layer.getChildFrame('body', index);392 body.contents().find("#typeName").val(typeName);393 body.contents().find("#name").val(name);394 body.contents().find("#id1").val(id1);395 body.contents().find("#id").val(id);396 },397 end: function () {398 $("#searchUserifAccount").click();399 }400 });401}402function updateServers(node) {403 var typeName = $("#typeName").val();404 var id = $("#id").val();405 var name = $("#name").val();406 var id1 = $("#id1").val();407 var path = $("#path").val();408 $.ajax({409 url: path+"/adminType/updateServers",410 data: {typeName: typeName,id: id,411 name: name,id1: id1},412 success: function (data) {413 if (data == "修改成功") {414 alert("修改成功");415 guanbi();416 } else {417 layer.alert("修改失败")418 }419 },420 end: function () {421 $("#searchUserifAccount").click();422 }423 })424}425//addType 添加服务类型426function addType() {427 layer.open({428 anim: 1,429 type: 2,430 title: '新增服务类型',431 shadeClose: true,432 shade: false,433 maxmin: true,434 id: 'addTypes',435 area: ['450', '400'],436 content: ['/jsp/Admin_ServerTypeadd.jsp'],437 end: function () {438 $("#searchUserifAccount").click();439 }440 });441}442//发布动态公告ajax443function addTypes(node) {444 var typeName = $("#typeName").val();445 var pid = $("#pid").val();446 var path = $("#path").val();447 $.ajax({448 url: path+"/adminType/addType",449 data: {typeName: typeName, pid: pid},450 success: function (data) {451 if (data == "添加成功") {452 alert("添加成功");453 guanbi();454 } else {455 layer.alert("添加失败")456 }457 },458 end: function () {459 $("#searchUserifAccount").click();460 }461 })462}463//区域查看详细的商家信息464function lookAreac(node) {465 var name = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.textContent;466 var address = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.textContent;467 var legal = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.textContent;468 var phone = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;469 var entryDate = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.textContent;470 var area = $(node).parent("div").parent("td").parent("tr")[0].firstChild.nextSibling.textContent;471 layer.open({472 anim: 1,473 type: 2,474 title: '查看详情',475 shadeClose: true,476 shade: false,477 maxmin: true,478 id: 'lookAffiche',479 area: ['400', '500'],480 content: ['/jsp/Admin_Areaclook.jsp'],481 success: function (layero, index) {482 var body = layer.getChildFrame('body', index);483 body.contents().find("#name").val(name);484 body.contents().find("#legal").val(legal);485 body.contents().find("#area").val(area);486 body.contents().find("#address").val(address);487 body.contents().find("#phone").val(phone);488 body.contents().find("#entryDate").val(entryDate);489 },490 end: function () {491 $("#searchUserifAccount").click();492 }493 });494}495//addareac 添加区域496function addareac() {497 layer.open({498 anim: 1,499 type: 2,500 title: '新增区域',501 shadeClose: true,502 shade: false,503 maxmin: true,504 id: 'addareacs',505 area: ['300', '250'],506 content: ['/jsp/Admin_Areacadd.jsp'],507 end: function () {508 $("#searchUserifAccount").click();509 }510 });511}512//添加区域 ajax513function addareacs(node) {514 var area = $("#area").val();515 var path = $("#path").val();516 $.ajax({517 url: path+"/adminAreac/addareac",518 data: {area: area},519 success: function (data) {520 if (data == "添加成功") {521 alert("添加成功");522 guanbi();523 } else {524 layer.alert("添加失败")525 }526 },527 end: function () {528 $("#searchUserifAccount").click();529 }530 })...

Full Screen

Full Screen

parser.js

Source:parser.js Github

copy

Full Screen

...33 };34 case "CallExpression": // may be any func call35 c.firstChild(); // Name of the function36 var callName = s.substring(c.from, c.to);37 c.nextSibling(); // Goto ArgList38 c.firstChild(); // Goto (39 c.nextSibling(); //Goto params40 var arg_arr = [];41 while (c.node.type.name != ")") {42 arg_arr.push(traverseExpr(c, s));43 c.nextSibling(); // Goto comma44 c.nextSibling(); // Skip comma45 }46 c.parent(); // Goto Arglist47 c.parent(); // Goto CallExpression48 return { tag: "funcall", name: callName, args: arg_arr };49 case "BinaryExpression":50 //console.log("Here");51 c.firstChild(); // First expr52 var left_expr = traverseExpr(c, s);53 //console.log(left_expr);54 c.nextSibling(); // goTo BinaryOperator55 var op = s.substring(c.from, c.to);56 if (!ast_1.BinOpMap.has(op)) {57 c.parent(); // Got back to BinaryExpression level58 throw new Error("ParseError: Binary Operator " + op + " not supported");59 }60 //console.log(op);61 c.nextSibling();62 var right_expr = traverseExpr(c, s);63 //console.log(right_expr);64 c.parent(); // return to BinaryExpr level65 return {66 tag: "binOperator",67 left_opr: left_expr,68 opr: ast_1.BinOpMap.get(op),69 right_opr: right_expr70 };71 case "ParenthesizedExpression":72 c.firstChild(); //goto (73 c.nextSibling();74 var innerArg = traverseExpr(c, s);75 c.nextSibling(); // Solve for inner expr76 c.nextSibling(); // goto ) -> Not required but good to have for debug77 c.parent(); // goto parent level78 return {79 tag: "paran",80 inner: innerArg81 };82 case "UnaryExpression":83 //console.log("Here");84 c.firstChild(); // In unaryOp85 var unary_op = s.substring(c.from, c.to);86 if (!ast_1.UniOpMap.has(unary_op)) {87 c.parent();88 throw new Error("ParseError: Invalid unary operator " + unary_op);89 }90 c.nextSibling(); // goto expr91 var UniOpExpr = traverseExpr(c, s);92 c.parent();93 return { tag: "UniOperator", opr: ast_1.UniOpMap.get(unary_op), right: UniOpExpr };94 default:95 throw new Error("ParseError: Could not parse expr at " + c.from + " " + c.to + ": " + s.substring(c.from, c.to));96 }97}98exports.traverseExpr = traverseExpr;99function traverseLiteral(c, s, value, type) {100 switch (String(c.node.type.name)) {101 case "Number":102 return { tag: "num", value: Number(value), type: ast_1.VarType.int };103 case "Boolean":104 if (value == "True") {105 return { tag: "bool", value: true, type: ast_1.VarType.bool };106 }107 if (value == "False") {108 return { tag: "bool", value: false, type: ast_1.VarType.bool };109 }110 break;111 case "None":112 return { tag: "none", value: null, type: ast_1.VarType.none };113 default:114 // Here check if its an expression and hanle accordingly115 throw new Error("Expected `" + type + "`; but got `" + String(c.node.type.name) + "`");116 }117}118exports.traverseLiteral = traverseLiteral;119function isExpression(e) {120 var exprStatements = ["ExpressionStatement", "BinaryExpression", "UnaryExpression", "ParenthesizedExpression", "CallExpression"];121 return exprStatements.includes(e);122}123exports.isExpression = isExpression;124function traverseTypeDef(c, s, name) {125 // Todo: Need to add checker for x:int = <expr> 126 switch (c.node.type.name) {127 case "TypeDef":128 c.firstChild(); // goto :129 c.nextSibling(); // goto type130 var t = s.substring(c.from, c.to);131 if (ast_1.TypeMap.has(t)) {132 var type = ast_1.TypeMap.get(t);133 c.parent(); //goto TypeDef134 c.nextSibling(); // goto =135 c.nextSibling(); // goto literal or right val. It cannot be another expression. Need to add that checker136 // check if it's an expression or variable name137 // const checkExpr = isExpression(String(c.node.type.name)) // Need to enhance this138 var value = s.substring(c.from, c.to);139 var myLit = traverseLiteral(c, s, value, type);140 return { name: name, type: type, value: myLit };141 }142 else {143 throw new Error("Invalid type annotation; there is no class named: " + t);144 }145 }146}147exports.traverseTypeDef = traverseTypeDef;148function traverseType(s, t) {149 switch (t.type.name) {150 case "VariableName":151 var name_1 = s.substring(t.from, t.to);152 if (!ast_1.TypeMap.has(name_1)) {153 throw new Error("ParseError: Type " + name_1 + " not allowed");154 }155 return ast_1.TypeMap.get(name_1);156 default:157 throw new Error("Unknown type: " + t.type.name);158 }159}160exports.traverseType = traverseType;161function traverseParameters(s, t) {162 t.firstChild(); // Focuses on open paren163 var parameters = [];164 t.nextSibling(); // Focuses on a VariableName165 while (t.type.name !== ")") {166 var name_2 = s.substring(t.from, t.to);167 t.nextSibling(); // Focuses on "TypeDef", hopefully, or "," if mistake168 var nextTagName = t.type.name; // NOTE(joe): a bit of a hack so the next line doesn't if-split169 if (nextTagName !== "TypeDef") {170 throw new Error("Missed type annotation for parameter " + name_2);171 }172 ;173 t.firstChild(); // Enter TypeDef174 t.nextSibling(); // Focuses on type itself175 var typ = traverseType(s, t);176 t.parent();177 t.nextSibling(); // Move on to comma or ")"178 parameters.push({ name: name_2, type: typ });179 t.nextSibling(); // Focuses on a VariableName180 }181 t.parent(); // Pop to ParamList182 return parameters;183}184exports.traverseParameters = traverseParameters;185function checkElif(c, s, ElifArray) {186 if (c.type.name != "elif") {187 return;188 }189 // Means we have elif190 c.nextSibling();191 var elifcond = traverseExpr(c, s);192 c.nextSibling(); // Body193 c.firstChild(); // goto :194 var elifbody = [];195 while (c.nextSibling()) {196 elifbody.push(traverseStmt(c, s));197 }198 c.parent(); // go back to body199 ElifArray.push({ cond: elifcond, body: elifbody });200 c.nextSibling(); // Again check for elif201 checkElif(c, s, ElifArray);202 return;203}204exports.checkElif = checkElif;205function traverseStmt(c, s) {206 switch (c.node.type.name) {207 case "AssignStatement":208 c.firstChild(); // go to name209 var name_3 = s.substring(c.from, c.to);210 c.nextSibling(); // go to equals or may be typdef211 if (String(c.node.type.name) === "TypeDef") {212 var typeDef = traverseTypeDef(c, s, name_3);213 c.parent(); // goto AssignStatement level214 return { tag: "varInit", name: name_3, value: typeDef };215 }216 else {217 // Means it is =218 c.nextSibling(); // go to right expr219 var rexpr = traverseExpr(c, s);220 c.parent(); // got to assignment level221 return { tag: "assign", name: name_3, value: rexpr };222 }223 case "ExpressionStatement":224 //console.log("Here");225 c.firstChild();226 var expr = traverseExpr(c, s);227 c.parent(); // pop going into stmt228 return { tag: "expr", expr: expr };229 case "IfStatement":230 c.firstChild(); // goto if231 c.nextSibling(); // goto cond expr232 var ifCondExpr = traverseExpr(c, s);233 c.nextSibling(); // Body234 c.firstChild(); // goto :235 //Multiple stataments inside if body236 var ifBodyStmt = [];237 while (c.nextSibling()) {238 ifBodyStmt.push(traverseStmt(c, s));239 }240 // Does the ifbody has return statement?241 // Should check in parser or typechecker?242 c.parent(); //Go back to if body243 //check if we have elif244 c.nextSibling(); //-> Here we are at elif or else or body ends245 var myLocalElifArr = [];246 // recursive function to gather all elif as we can have multiple elif247 checkElif(c, s, myLocalElifArr);248 var elifSeen = 0;249 if (myLocalElifArr.length >= 1) {250 elifSeen += 1;251 }252 // Not needed253 // if(myLocalElifArr.length>=1 && c.type.name!="else"){254 // throw new Error("ParseError: Expected else after elif");255 // }256 // c.nextSibling(); // May be else or body end. Actualy it must have else if we have elif257 var elseSeen = false;258 // array to hold elsebody statements259 var elsebody = [];260 if (c.type.name == "else") {261 elseSeen = true;262 c.nextSibling(); // body263 //var elsecondexpr = traverseExpr(c,s);264 //c.nextSibling(); // Body265 c.firstChild(); //goto :266 while (c.nextSibling()) {267 elsebody.push(traverseStmt(c, s));268 }269 c.parent();270 }271 c.parent(); // go back to IfStatement272 var myElse;273 if (elseSeen) {274 myElse = { body: elsebody };275 }276 if (elifSeen && !elseSeen) {277 return { tag: "if", cond: ifCondExpr, ifbody: ifBodyStmt, elif: myLocalElifArr };278 }279 if (elifSeen && elseSeen) {280 return { tag: "if", cond: ifCondExpr, ifbody: ifBodyStmt, elif: myLocalElifArr, "else": myElse };281 }282 if (elseSeen) {283 return { tag: "if", cond: ifCondExpr, ifbody: ifBodyStmt, "else": myElse };284 }285 return { tag: "if", cond: ifCondExpr, ifbody: ifBodyStmt };286 case "WhileStatement":287 // how to do?? Same as if??288 c.firstChild(); // goto while289 c.nextSibling(); // condexpr290 var whileExpr = traverseExpr(c, s);291 c.nextSibling(); //goto body292 c.firstChild(); // goto :293 var mywhilebody = [];294 while (c.nextSibling()) {295 mywhilebody.push(traverseStmt(c, s));296 }297 c.parent(); // goback to body298 c.parent(); // goback to whileStatement299 return { tag: "while", cond: whileExpr, body: mywhilebody };300 case "FunctionDefinition":301 c.firstChild(); // Focus on def302 c.nextSibling(); // Focus on name of function303 var funname = s.substring(c.from, c.to);304 c.nextSibling(); // Focus on ParamList305 var params = traverseParameters(s, c);306 c.nextSibling(); // Focus on Body or TypeDef307 var ret = ast_1.VarType.none;308 var maybeTD = c;309 if (maybeTD.type.name === "TypeDef") {310 c.firstChild();311 ret = traverseType(s, c);312 c.parent();313 }314 c.nextSibling(); // Focus on Body315 c.firstChild(); // Focus on :316 var body = [];317 while (c.nextSibling()) {318 body.push(traverseStmt(c, s));319 }320 var varInit_1 = [];321 // For VarInit field in FuncDef322 body.forEach(function (b) {323 if (b.tag == "varInit") {324 varInit_1.push(b.value);325 }326 });327 c.parent(); // Pop to Body328 c.parent(); // Pop to FunctionDefinition329 return {330 tag: "FuncDef",331 name: funname,332 params: params, init: varInit_1, body: body, ret: ret333 };334 case "ReturnStatement":335 c.firstChild(); // On return336 c.nextSibling(); // Go to expr337 // mean func has return; and not like return <expr>. In such case assign the type to none338 // n.nextSibling will not change if we have only return339 if (c.type.name == "return") {340 c.parent();341 return { tag: "return" };342 }343 var returnExpr = traverseExpr(c, s);344 c.parent(); // Go back to parent level345 return { tag: "return", "return": returnExpr };346 case "PassStatement":347 c.parent();348 return { tag: "pass" };349 default:350 throw new Error("ParseError: Could not parse stmt at " + c.node.from + " " + c.node.to + ": " + s.substring(c.from, c.to));351 }352}353exports.traverseStmt = traverseStmt;354function traverse(c, s) {355 switch (c.node.type.name) {356 case "Script":357 var stmts = [];358 c.firstChild();359 do {360 stmts.push(traverseStmt(c, s));361 } while (c.nextSibling());362 console.log("traversed " + stmts.length + " statements ", stmts, "stopped at ", c.node);363 return stmts;364 default:365 throw new Error("ParseError: Could not parse program at " + c.node.from + " " + c.node.to);366 }367}368exports.traverse = traverse;369function parseProgram(source) {370 var t = lezer_python_1.parser.parse(source);371 return traverse(t.cursor(), source);372}...

Full Screen

Full Screen

DraftTreeInvariants-test.js

Source:DraftTreeInvariants-test.js Github

copy

Full Screen

1/**2 * Copyright (c) Facebook, Inc. and its affiliates.3 *4 * This source code is licensed under the MIT license found in the5 * LICENSE file in the root directory of this source tree.6 *7 * @emails oncall+draft_js8 * @flow strict-local9 * @format10 */11'use strict';12jest.disableAutomock();13// missing parent -> child connection14const ContentBlockNode = require('ContentBlockNode');15const DraftTreeInvariants = require('DraftTreeInvariants');16const Immutable = require('immutable');17test('single block', () =>18 expect(19 DraftTreeInvariants.isValidTree(20 Immutable.OrderedMap({21 A: new ContentBlockNode({22 key: 'A',23 parent: null,24 text: 'Charlie',25 children: Immutable.List([]),26 prevSibling: null,27 nextSibling: null,28 }),29 }),30 ),31 ).toBe(true));32// valid trees with children and siblings33test('simple valid tree', () =>34 expect(35 DraftTreeInvariants.isValidTree(36 Immutable.OrderedMap({37 A: new ContentBlockNode({38 key: 'A',39 parent: null,40 text: 'alpha',41 children: Immutable.List([]),42 prevSibling: null,43 nextSibling: 'B',44 }),45 B: new ContentBlockNode({46 key: 'B',47 parent: null,48 text: '',49 children: Immutable.List(['C', 'D']),50 prevSibling: 'A',51 nextSibling: 'E',52 }),53 C: new ContentBlockNode({54 key: 'C',55 parent: 'B',56 text: 'charlie',57 children: Immutable.List([]),58 prevSibling: null,59 nextSibling: 'D',60 }),61 D: new ContentBlockNode({62 key: 'D',63 parent: 'B',64 text: 'delta',65 children: Immutable.List([]),66 prevSibling: 'C',67 nextSibling: null,68 }),69 E: new ContentBlockNode({70 key: 'E',71 parent: null,72 text: 'epsilon',73 children: Immutable.List([]),74 prevSibling: 'B',75 nextSibling: null,76 }),77 }),78 ),79 ).toBe(true));80test('complex valid tree', () =>81 expect(82 DraftTreeInvariants.isValidTree(83 Immutable.OrderedMap({84 A: new ContentBlockNode({85 key: 'A',86 parent: null,87 text: '',88 children: Immutable.List(['B', 'D', 'Z']),89 prevSibling: 'X',90 nextSibling: 'C',91 }),92 B: new ContentBlockNode({93 key: 'B',94 parent: 'A',95 text: 'beta',96 children: Immutable.List([]),97 prevSibling: null,98 nextSibling: 'D',99 }),100 C: new ContentBlockNode({101 key: 'C',102 parent: null,103 text: 'charlie',104 children: Immutable.List([]),105 prevSibling: 'A',106 nextSibling: null,107 }),108 D: new ContentBlockNode({109 key: 'D',110 parent: 'A',111 text: '',112 children: Immutable.List(['E', 'G', 'F']),113 prevSibling: 'B',114 nextSibling: 'Z',115 }),116 E: new ContentBlockNode({117 key: 'E',118 parent: 'D',119 text: 'epsilon',120 children: Immutable.List([]),121 prevSibling: null,122 nextSibling: 'F',123 }),124 F: new ContentBlockNode({125 key: 'F',126 parent: 'D',127 text: 'fish',128 children: Immutable.List([]),129 prevSibling: 'E',130 nextSibling: 'G',131 }),132 G: new ContentBlockNode({133 key: 'G',134 parent: 'D',135 text: 'gamma',136 children: Immutable.List([]),137 prevSibling: 'F',138 nextSibling: null,139 }),140 X: new ContentBlockNode({141 key: 'X',142 parent: null,143 text: '',144 children: Immutable.List(['Y']),145 prevSibling: null,146 nextSibling: 'A',147 }),148 Y: new ContentBlockNode({149 key: 'Y',150 parent: 'X',151 text: 'yeti',152 children: Immutable.List([]),153 prevSibling: null,154 nextSibling: null,155 }),156 Z: new ContentBlockNode({157 key: 'Z',158 parent: 'A',159 text: 'zeta',160 children: Immutable.List([]),161 prevSibling: 'D',162 nextSibling: null,163 }),164 }),165 ),166 ).toBe(true));167test('missing child -> parent pointer', () =>168 expect(169 DraftTreeInvariants.isValidTree(170 Immutable.OrderedMap({171 A: new ContentBlockNode({172 key: 'A',173 parent: null,174 text: 'alpha',175 children: Immutable.List([]),176 prevSibling: null,177 nextSibling: 'B',178 }),179 B: new ContentBlockNode({180 key: 'B',181 parent: null,182 text: '',183 children: Immutable.List(['C', 'D']),184 prevSibling: 'A',185 nextSibling: 'E',186 }),187 C: new ContentBlockNode({188 key: 'C',189 parent: 'B',190 text: 'charlie',191 children: Immutable.List([]),192 prevSibling: null,193 nextSibling: 'D',194 }),195 D: new ContentBlockNode({196 key: 'D',197 parent: null, // should be B198 text: 'delta',199 children: Immutable.List([]),200 prevSibling: 'C',201 nextSibling: null,202 }),203 E: new ContentBlockNode({204 key: 'E',205 parent: null,206 text: 'epsilon',207 children: Immutable.List([]),208 prevSibling: 'B',209 nextSibling: null,210 }),211 }),212 ),213 ).toBe(false));214test('missing parent -> child pointer', () =>215 expect(216 DraftTreeInvariants.isValidTree(217 Immutable.OrderedMap({218 A: new ContentBlockNode({219 key: 'A',220 parent: null,221 text: 'alpha',222 children: Immutable.List([]),223 prevSibling: null,224 nextSibling: 'B',225 }),226 B: new ContentBlockNode({227 key: 'B',228 parent: null,229 text: '',230 children: Immutable.List(['C']), // should be [C, D]231 prevSibling: 'A',232 nextSibling: 'E',233 }),234 C: new ContentBlockNode({235 key: 'C',236 parent: 'B',237 text: 'charlie',238 children: Immutable.List([]),239 prevSibling: null,240 nextSibling: 'D',241 }),242 D: new ContentBlockNode({243 key: 'D',244 parent: 'B',245 text: 'delta',246 children: Immutable.List([]),247 prevSibling: 'C',248 nextSibling: null,249 }),250 E: new ContentBlockNode({251 key: 'E',252 parent: null,253 text: 'epsilon',254 children: Immutable.List([]),255 prevSibling: 'B',256 nextSibling: null,257 }),258 }),259 ),260 ).toBe(false));261// missing prevSibling262test('missing prev pointer', () =>263 expect(264 DraftTreeInvariants.isValidTree(265 Immutable.OrderedMap({266 A: new ContentBlockNode({267 key: 'A',268 parent: null,269 text: 'alpha',270 children: Immutable.List([]),271 prevSibling: null,272 nextSibling: 'B',273 }),274 B: new ContentBlockNode({275 key: 'B',276 parent: null,277 text: '',278 children: Immutable.List(['C', 'D']),279 prevSibling: 'A',280 nextSibling: 'E',281 }),282 C: new ContentBlockNode({283 key: 'C',284 parent: 'B',285 text: 'charlie',286 children: Immutable.List([]),287 prevSibling: null,288 nextSibling: 'D',289 }),290 D: new ContentBlockNode({291 key: 'D',292 parent: 'B',293 text: 'delta',294 children: Immutable.List([]),295 prevSibling: null, // should be D296 nextSibling: null,297 }),298 E: new ContentBlockNode({299 key: 'E',300 parent: null,301 text: 'epsilon',302 children: Immutable.List([]),303 prevSibling: 'B',304 nextSibling: null,305 }),306 }),307 ),308 ).toBe(false));309// missing nextSibling310test('missing nextSibling pointer', () =>311 expect(312 DraftTreeInvariants.isValidTree(313 Immutable.OrderedMap({314 A: new ContentBlockNode({315 key: 'A',316 parent: null,317 text: 'alpha',318 children: Immutable.List([]),319 prevSibling: null,320 nextSibling: 'B',321 }),322 B: new ContentBlockNode({323 key: 'B',324 parent: null,325 text: '',326 children: Immutable.List(['C', 'D']),327 prevSibling: 'A',328 nextSibling: null, // should be E329 }),330 C: new ContentBlockNode({331 key: 'C',332 parent: 'B',333 text: 'charlie',334 children: Immutable.List([]),335 prevSibling: null,336 nextSibling: 'D',337 }),338 D: new ContentBlockNode({339 key: 'D',340 parent: 'B',341 text: 'delta',342 children: Immutable.List([]),343 prevSibling: 'C',344 nextSibling: null,345 }),346 E: new ContentBlockNode({347 key: 'E',348 parent: null,349 text: 'epsilon',350 children: Immutable.List([]),351 prevSibling: 'B',352 nextSibling: null,353 }),354 }),355 ),356 ).toBe(false));357// two-node cycle C <-> D358test('missing child -> parent connection', () =>359 expect(360 DraftTreeInvariants.isValidTree(361 Immutable.OrderedMap({362 A: new ContentBlockNode({363 key: 'A',364 parent: null,365 text: 'alpha',366 children: Immutable.List([]),367 prevSibling: null,368 nextSibling: 'B',369 }),370 B: new ContentBlockNode({371 key: 'B',372 parent: null,373 text: '',374 children: Immutable.List(['C', 'D']),375 prevSibling: 'A',376 nextSibling: 'E',377 }),378 C: new ContentBlockNode({379 key: 'C',380 parent: 'B',381 text: 'charlie',382 children: Immutable.List([]),383 prevSibling: 'D', // should be null384 nextSibling: 'D',385 }),386 D: new ContentBlockNode({387 key: 'D',388 parent: 'B',389 text: 'delta',390 children: Immutable.List([]),391 prevSibling: 'C',392 nextSibling: 'C', // should be null393 }),394 E: new ContentBlockNode({395 key: 'E',396 parent: null,397 text: 'epsilon',398 children: Immutable.List([]),399 prevSibling: 'B',400 nextSibling: null,401 }),402 }),403 ),404 ).toBe(false));405// leaf has children406test('missing child -> parent connection', () =>407 expect(408 DraftTreeInvariants.isValidTree(409 Immutable.OrderedMap({410 A: new ContentBlockNode({411 key: 'A',412 parent: null,413 text: 'alpha',414 children: Immutable.List([]),415 prevSibling: null,416 nextSibling: 'B',417 }),418 B: new ContentBlockNode({419 key: 'B',420 parent: null,421 text: '',422 children: Immutable.List(['C', 'D']),423 prevSibling: 'A',424 nextSibling: 'E',425 }),426 C: new ContentBlockNode({427 key: 'C',428 parent: 'B',429 text: 'charlie', // should be ''430 children: Immutable.List(['F']),431 prevSibling: null,432 nextSibling: 'D',433 }),434 D: new ContentBlockNode({435 key: 'D',436 parent: 'B',437 text: 'delta',438 children: Immutable.List([]),439 prevSibling: 'C',440 nextSibling: null,441 }),442 E: new ContentBlockNode({443 key: 'E',444 parent: null,445 text: 'epsilon',446 children: Immutable.List([]),447 prevSibling: 'B',448 nextSibling: null,449 }),450 F: new ContentBlockNode({451 key: 'F',452 parent: 'C',453 text: 'fish',454 children: Immutable.List([]),455 prevSibling: null,456 nextSibling: null,457 }),458 }),459 ),460 ).toBe(false));461// unconnected tree (two clusters not connected by parent-child pointers)462test('unconnected tree', () =>463 expect(464 DraftTreeInvariants.isValidTree(465 Immutable.OrderedMap({466 A: new ContentBlockNode({467 key: 'A',468 parent: null,469 text: '',470 children: Immutable.List(['B', 'Z']), // should be [B, D, Z]471 prevSibling: 'X',472 nextSibling: 'C',473 }),474 B: new ContentBlockNode({475 key: 'B',476 parent: 'A',477 text: 'beta',478 children: Immutable.List([]),479 prevSibling: null,480 nextSibling: 'Z',481 }),482 C: new ContentBlockNode({483 key: 'C',484 parent: null,485 text: 'charlie',486 children: Immutable.List([]),487 prevSibling: 'A',488 nextSibling: null,489 }),490 D: new ContentBlockNode({491 key: 'D',492 parent: null,493 text: '',494 children: Immutable.List(['E', 'G', 'F']),495 prevSibling: null,496 nextSibling: null,497 }),498 E: new ContentBlockNode({499 key: 'E',500 parent: 'D',501 text: 'epsilon',502 children: Immutable.List([]),503 prevSibling: null,504 nextSibling: 'F',505 }),506 F: new ContentBlockNode({507 key: 'F',508 parent: 'D',509 text: 'fish',510 children: Immutable.List([]),511 prevSibling: 'E',512 nextSibling: 'G',513 }),514 G: new ContentBlockNode({515 key: 'G',516 parent: 'D',517 text: 'gamma',518 children: Immutable.List([]),519 prevSibling: 'F',520 nextSibling: null,521 }),522 X: new ContentBlockNode({523 key: 'X',524 parent: null,525 text: '',526 children: Immutable.List(['Y']),527 prevSibling: null,528 nextSibling: 'A',529 }),530 Y: new ContentBlockNode({531 key: 'Y',532 parent: 'X',533 text: 'yeti',534 children: Immutable.List([]),535 prevSibling: null,536 nextSibling: null,537 }),538 Z: new ContentBlockNode({539 key: 'Z',540 parent: 'A',541 text: 'zeta',542 children: Immutable.List([]),543 prevSibling: 'B',544 nextSibling: null,545 }),546 }),547 ),...

Full Screen

Full Screen

output.js

Source:output.js Github

copy

Full Screen

1import { template as _$template } from "r-dom";2import { memo as _$memo } from "r-dom";3import { For as _$For } from "r-dom";4import { createComponent as _$createComponent } from "r-dom";5import { mergeProps as _$mergeProps } from "r-dom";6import { getNextElement as _$getNextElement } from "r-dom";7import { getNextMarker as _$getNextMarker } from "r-dom";8import { insert as _$insert } from "r-dom";9const _tmpl$ = /*#__PURE__*/ _$template(`<div>Hello <!#><!/></div>`, 4),10 _tmpl$2 = /*#__PURE__*/ _$template(`<div></div>`, 2),11 _tmpl$3 = /*#__PURE__*/ _$template(`<div>From Parent</div>`, 2),12 _tmpl$4 = /*#__PURE__*/ _$template(`<div><!#><!/><!#><!/><!#><!/></div>`, 8),13 _tmpl$5 = /*#__PURE__*/ _$template(14 `<div><!#><!/> | <!#><!/> | <!#><!/> | <!#><!/> | <!#><!/> | <!#><!/></div>`,15 1416 ),17 _tmpl$6 = /*#__PURE__*/ _$template(18 `<div><!#><!/> | <!#><!/><!#><!/> | <!#><!/><!#><!/> | <!#><!/></div>`,19 1420 ),21 _tmpl$7 = /*#__PURE__*/ _$template(`<div> | <!#><!/> | | | <!#><!/> | </div>`, 6),22 _tmpl$8 = /*#__PURE__*/ _$template(`<span>1</span>`, 2),23 _tmpl$9 = /*#__PURE__*/ _$template(`<span>2</span>`, 2),24 _tmpl$10 = /*#__PURE__*/ _$template(`<span>3</span>`, 2);25import { Show } from "somewhere";26const Child = props => {27 const [s, set] = createSignal();28 return [29 (() => {30 const _el$ = _$getNextElement(_tmpl$),31 _el$2 = _el$.firstChild,32 _el$3 = _el$2.nextSibling,33 [_el$4, _co$] = _$getNextMarker(_el$3.nextSibling);34 const _ref$ = props.ref;35 typeof _ref$ === "function" ? _ref$(_el$) : (props.ref = _el$);36 _$insert(_el$, () => props.name, _el$4, _co$);37 return _el$;38 })(),39 (() => {40 const _el$5 = _$getNextElement(_tmpl$2);41 set(_el$5);42 _$insert(_el$5, () => props.children);43 return _el$5;44 })()45 ];46};47const template = props => {48 let childRef;49 const { content } = props;50 return (() => {51 const _el$6 = _$getNextElement(_tmpl$4),52 _el$9 = _el$6.firstChild,53 [_el$10, _co$2] = _$getNextMarker(_el$9.nextSibling),54 _el$11 = _el$10.nextSibling,55 [_el$12, _co$3] = _$getNextMarker(_el$11.nextSibling),56 _el$13 = _el$12.nextSibling,57 [_el$14, _co$4] = _$getNextMarker(_el$13.nextSibling);58 _$insert(59 _el$6,60 _$createComponent(61 Child,62 _$mergeProps(63 {64 name: "John"65 },66 props,67 {68 ref(r$) {69 const _ref$2 = childRef;70 typeof _ref$2 === "function" ? _ref$2(r$) : (childRef = r$);71 },72 booleanProperty: true,73 get children() {74 return _$getNextElement(_tmpl$3);75 }76 }77 )78 ),79 _el$10,80 _co$281 );82 _$insert(83 _el$6,84 _$createComponent(85 Child,86 _$mergeProps(87 {88 name: "Jason"89 },90 dynamicSpread,91 {92 ref(r$) {93 const _ref$3 = props.ref;94 typeof _ref$3 === "function" ? _ref$3(r$) : (props.ref = r$);95 },96 get children() {97 const _el$8 = _$getNextElement(_tmpl$2);98 _$insert(_el$8, content);99 return _el$8;100 }101 }102 )103 ),104 _el$12,105 _co$3106 );107 _$insert(108 _el$6,109 _$createComponent(Context.Consumer, {110 ref(r$) {111 const _ref$4 = props.consumerRef();112 typeof _ref$4 === "function" && _ref$4(r$);113 },114 children: context => context115 }),116 _el$14,117 _co$4118 );119 return _el$6;120 })();121};122const template2 = _$createComponent(Child, {123 name: "Jake",124 get dynamic() {125 return state.data;126 },127 stale: state.data,128 handleClick: clickHandler,129 get ["hyphen-ated"]() {130 return state.data;131 },132 ref: el => (e = el)133});134const template3 = _$createComponent(Child, {135 get children() {136 return [137 _$getNextElement(_tmpl$2),138 _$getNextElement(_tmpl$2),139 _$getNextElement(_tmpl$2),140 "After"141 ];142 }143});144const [s, set] = createSignal();145const template4 = _$createComponent(Child, {146 ref: set,147 get children() {148 return _$getNextElement(_tmpl$2);149 }150});151const template5 = _$createComponent(Child, {152 get dynamic() {153 return state.dynamic;154 },155 get children() {156 return state.dynamic;157 }158}); // builtIns159const template6 = _$createComponent(_$For, {160 get each() {161 return state.list;162 },163 get fallback() {164 return _$createComponent(Loading, {});165 },166 children: item =>167 _$createComponent(Show, {168 get when() {169 return state.condition;170 },171 children: item172 })173});174const template7 = _$createComponent(Child, {175 get children() {176 return [_$getNextElement(_tmpl$2), _$memo(() => state.dynamic)];177 }178});179const template8 = _$createComponent(Child, {180 get children() {181 return [item => item, item => item];182 }183});184const template9 = _$createComponent(_garbage, {185 children: "Hi"186});187const template10 = (() => {188 const _el$20 = _$getNextElement(_tmpl$5),189 _el$26 = _el$20.firstChild,190 [_el$27, _co$5] = _$getNextMarker(_el$26.nextSibling),191 _el$21 = _el$27.nextSibling,192 _el$28 = _el$21.nextSibling,193 [_el$29, _co$6] = _$getNextMarker(_el$28.nextSibling),194 _el$22 = _el$29.nextSibling,195 _el$30 = _el$22.nextSibling,196 [_el$31, _co$7] = _$getNextMarker(_el$30.nextSibling),197 _el$23 = _el$31.nextSibling,198 _el$32 = _el$23.nextSibling,199 [_el$33, _co$8] = _$getNextMarker(_el$32.nextSibling),200 _el$24 = _el$33.nextSibling,201 _el$34 = _el$24.nextSibling,202 [_el$35, _co$9] = _$getNextMarker(_el$34.nextSibling),203 _el$25 = _el$35.nextSibling,204 _el$36 = _el$25.nextSibling,205 [_el$37, _co$10] = _$getNextMarker(_el$36.nextSibling);206 _$insert(207 _el$20,208 _$createComponent(Link, {209 children: "new"210 }),211 _el$27,212 _co$5213 );214 _$insert(215 _el$20,216 _$createComponent(Link, {217 children: "comments"218 }),219 _el$29,220 _co$6221 );222 _$insert(223 _el$20,224 _$createComponent(Link, {225 children: "show"226 }),227 _el$31,228 _co$7229 );230 _$insert(231 _el$20,232 _$createComponent(Link, {233 children: "ask"234 }),235 _el$33,236 _co$8237 );238 _$insert(239 _el$20,240 _$createComponent(Link, {241 children: "jobs"242 }),243 _el$35,244 _co$9245 );246 _$insert(247 _el$20,248 _$createComponent(Link, {249 children: "submit"250 }),251 _el$37,252 _co$10253 );254 return _el$20;255})();256const template11 = (() => {257 const _el$38 = _$getNextElement(_tmpl$6),258 _el$42 = _el$38.firstChild,259 [_el$43, _co$11] = _$getNextMarker(_el$42.nextSibling),260 _el$39 = _el$43.nextSibling,261 _el$44 = _el$39.nextSibling,262 [_el$45, _co$12] = _$getNextMarker(_el$44.nextSibling),263 _el$46 = _el$45.nextSibling,264 [_el$47, _co$13] = _$getNextMarker(_el$46.nextSibling),265 _el$40 = _el$47.nextSibling,266 _el$48 = _el$40.nextSibling,267 [_el$49, _co$14] = _$getNextMarker(_el$48.nextSibling),268 _el$50 = _el$49.nextSibling,269 [_el$51, _co$15] = _$getNextMarker(_el$50.nextSibling),270 _el$41 = _el$51.nextSibling,271 _el$52 = _el$41.nextSibling,272 [_el$53, _co$16] = _$getNextMarker(_el$52.nextSibling);273 _$insert(274 _el$38,275 _$createComponent(Link, {276 children: "new"277 }),278 _el$43,279 _co$11280 );281 _$insert(282 _el$38,283 _$createComponent(Link, {284 children: "comments"285 }),286 _el$45,287 _co$12288 );289 _$insert(290 _el$38,291 _$createComponent(Link, {292 children: "show"293 }),294 _el$47,295 _co$13296 );297 _$insert(298 _el$38,299 _$createComponent(Link, {300 children: "ask"301 }),302 _el$49,303 _co$14304 );305 _$insert(306 _el$38,307 _$createComponent(Link, {308 children: "jobs"309 }),310 _el$51,311 _co$15312 );313 _$insert(314 _el$38,315 _$createComponent(Link, {316 children: "submit"317 }),318 _el$53,319 _co$16320 );321 return _el$38;322})();323const template12 = (() => {324 const _el$54 = _$getNextElement(_tmpl$7),325 _el$55 = _el$54.firstChild,326 _el$60 = _el$55.nextSibling,327 [_el$61, _co$17] = _$getNextMarker(_el$60.nextSibling),328 _el$56 = _el$61.nextSibling,329 _el$62 = _el$56.nextSibling,330 [_el$63, _co$18] = _$getNextMarker(_el$62.nextSibling),331 _el$59 = _el$63.nextSibling;332 _$insert(333 _el$54,334 _$createComponent(Link, {335 children: "comments"336 }),337 _el$61,338 _co$17339 );340 _$insert(341 _el$54,342 _$createComponent(Link, {343 children: "show"344 }),345 _el$63,346 _co$18347 );348 return _el$54;349})();350class Template13 {351 render() {352 const _self$ = this;353 _$createComponent(Component, {354 get prop() {355 return _self$.something;356 },357 onClick: () => _self$.shouldStay,358 get children() {359 return _$createComponent(Nested, {360 get prop() {361 return _self$.data;362 },363 get children() {364 return _self$.content;365 }366 });367 }368 });369 }370}371const Template14 = _$createComponent(Component, {372 get children() {373 return data();374 }375});376const Template15 = _$createComponent(Component, props);377const Template16 = _$createComponent(378 Component,379 _$mergeProps(380 {381 something: something382 },383 props384 )385);386const Template17 = _$createComponent(Pre, {387 get children() {388 return [389 _$getNextElement(_tmpl$8),390 " ",391 _$getNextElement(_tmpl$9),392 " ",393 _$getNextElement(_tmpl$10)394 ];395 }396});397const Template18 = _$createComponent(Pre, {398 get children() {399 return [_$getNextElement(_tmpl$8), _$getNextElement(_tmpl$9), _$getNextElement(_tmpl$10)];400 }401});402const Template19 = _$createComponent(403 Component,404 _$mergeProps(() => s.dynamic())405);406const Template20 = _$createComponent(Component, {407 get ["class"]() {408 return prop.red ? "red" : "green";409 }410});411const template21 = _$createComponent(412 Component,413 _$mergeProps(() => ({414 get [key()]() {415 return props.value;416 }417 }))...

Full Screen

Full Screen

Model.test.js

Source:Model.test.js Github

copy

Full Screen

1import '@testing-library/jest-dom/extend-expect';2import renderer from 'react-test-renderer';3import { render, screen } from '@testing-library/react';4import Model from '../../components/Model';5const company = {6 symbol: 'TS',7 companyName: 'Test Co',8 ceo: 'Devs',9 website: 'www.test.com',10 ipoDate: '2021-07-31',11 industry: 'SF',12 sector: 'Tech',13 fullTimeEmployees: '1000',14 price: 10,15 changes: 2,16 volAvg: 1255,17 mktCap: 5000,18 dcf: 8,19 description: 'Test componany for Model',20};21describe('Snapshot of the Model component', () => {22 it('should render correctly', () => {23 const tree = renderer.create(<Model company={company} />).toJSON();24 expect(tree).toMatchSnapshot();25 });26});27describe('Querying the Model component', () => {28 beforeEach(() => render(<Model company={company} />));29 it('should have nodes for company name, ceo and website', () => {30 const companyName = screen.getByText('Company Name:').nextSibling.nextSibling;31 expect(companyName).toHaveTextContent(company.companyName);32 const companyCeo = screen.getByText('CEO:').nextSibling.nextSibling;33 expect(companyCeo).toHaveTextContent(company.ceo);34 const companyWebsite = screen.getByText('Website:').nextSibling.nextSibling;35 expect(companyWebsite).toHaveAttribute('href', company.website);36 expect(companyWebsite).toHaveTextContent(company.website);37 });38 it('should have nodes for company symbol, sector and industry', () => {39 const companySymbol = screen.getByText('Symbol:').nextSibling.nextSibling;40 expect(companySymbol).toHaveTextContent(company.symbol);41 const companySector = screen.getByText('Sector:').nextSibling.nextSibling;42 expect(companySector).toHaveTextContent(company.sector);43 const companyIndustry = screen.getByText('Industry:').nextSibling.nextSibling;44 expect(companyIndustry).toHaveTextContent(company.industry);45 });46 it('should convert large values of company full-time employees, market cap and volume average to locale string ', () => {47 const companyEmployees = screen.getByText('Fulltime Employees:').nextSibling.nextSibling;48 expect(companyEmployees).not.toHaveTextContent(company.fullTimeEmployees);49 expect(companyEmployees).toHaveTextContent('1,000');50 const companyMarketCap = screen.getByText('Market Cap:').nextSibling.nextSibling;51 expect(companyMarketCap).not.toHaveTextContent(company.mktCap);52 expect(companyMarketCap).toHaveTextContent('5,000');53 const companyVolumeAvg = screen.getByText('Volume Average:').nextSibling.nextSibling;54 expect(companyVolumeAvg).not.toHaveTextContent(company.volAvg);55 expect(companyVolumeAvg).toHaveTextContent('1,255');56 });57 it('should have nodes for company IPO date, price, DCF, changes and description', () => {58 const companyIpoDate = screen.getByText('IPO Date:').nextSibling.nextSibling;59 expect(companyIpoDate).toHaveTextContent(company.ipoDate);60 const companyPrice = screen.getByText('Price:').nextSibling.nextSibling;61 expect(companyPrice).toHaveTextContent(company.price);62 const companyDcf = screen.getByText('Discounted Cash Flow:').nextSibling.nextSibling;63 expect(companyDcf).toHaveTextContent(company.dcf);64 const companyDescription = screen.getByText('Description:').nextSibling.nextSibling;65 expect(companyDescription).toHaveTextContent(company.description);66 });...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1const form = document.querySelector('#form-data');2form.addEventListener('submit', event => {3 event.preventDefault();4 const firstName = form.firstName5 const lastName = form.lastName6 const emailAddress = form.emailAddress7 const password = form.password8 if(firstName.value.trim()==""){9 firstName.classList.add('form-input-error');10 let iconError = firstName.nextSibling.nextSibling;11 let messageError = firstName.nextSibling.nextSibling.nextSibling.nextSibling;12 iconError.style.display = "block";13 messageError.style.display = "block";14 firstName.value = ""15 }else{16 firstName.classList.remove('form-input-error');17 let iconError = firstName.nextSibling.nextSibling;18 let messageError = firstName.nextSibling.nextSibling.nextSibling.nextSibling;19 iconError.style.display = "none";20 messageError.style.display = "none";21 }22 if(lastName.value.trim()==""){23 lastName.classList.add('form-input-error');24 let iconError = lastName.nextSibling.nextSibling;25 let messageError = lastName.nextSibling.nextSibling.nextSibling.nextSibling;26 iconError.style.display = "block";27 messageError.style.display = "block";28 lastName.value = ""29 }else{30 lastName.classList.remove('form-input-error');31 let iconError = lastName.nextSibling.nextSibling;32 let messageError = lastName.nextSibling.nextSibling.nextSibling.nextSibling;33 iconError.style.display = "none";34 messageError.style.display = "none";35 }36 if(emailAddress.value.trim()==""){37 emailAddress.classList.add('form-input-error');38 let iconError = emailAddress.nextSibling.nextSibling;39 let messageError = emailAddress.nextSibling.nextSibling.nextSibling.nextSibling;40 iconError.style.display = "block";41 messageError.style.display = "block";42 emailAddress.value = ""43 }else{44 emailAddress.classList.remove('form-input-error');45 let iconError = emailAddress.nextSibling.nextSibling;46 let messageError = emailAddress.nextSibling.nextSibling.nextSibling.nextSibling;47 iconError.style.display = "none";48 messageError.style.display = "none";49 }50 if(password.value.trim()==""){51 password.classList.add('form-input-error');52 let iconError = password.nextSibling.nextSibling;53 let messageError = password.nextSibling.nextSibling.nextSibling.nextSibling;54 iconError.style.display = "block";55 messageError.style.display = "block";56 password.value = ""57 }else{58 password.classList.remove('form-input-error');59 let iconError = password.nextSibling.nextSibling;60 let messageError = password.nextSibling.nextSibling.nextSibling.nextSibling;61 iconError.style.display = "none";62 messageError.style.display = "none";63 }...

Full Screen

Full Screen

switch.js

Source:switch.js Github

copy

Full Screen

1$(document).ready(function(){2 var cl = $(".mui-switch");3 for(var i=0;i<cl.length;i++){4 if(cl[i].checked){5 cl[i].nextSibling.innerText='开启';6 cl[i].nextSibling.style.color="#FFFFFF";7 cl[i].nextSibling.style.marginLeft='0px';8 }else{9 cl[i].nextSibling.innerText='关闭';10 cl[i].nextSibling.style.color="#D2D2D2";11 cl[i].nextSibling.style.marginLeft='16px';12 }13 }14 cl.click(function(){15 if(this.checked){16 this.nextSibling.innerText='开启';17 this.nextSibling.style.color="#FFFFFF";18 this.nextSibling.style.marginLeft='0px';19 }else{20 this.nextSibling.innerText='关闭';21 this.nextSibling.style.color="#D2D2D2";22 this.nextSibling.style.marginLeft='16px'; 23 24 }25 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const element = await page.$('input[name="q"]');7 console.log(element);8 const siblingElement = await element.nextSibling();9 console.log(siblingElement);10 await browser.close();11})();12ElementHandle {13 _channel: ChannelOwner {14 _channel: Connection {15 _events: [Object: null prototype] {},16 _callbacks: [Object: null prototype] {},17 _sessions: [Object: null prototype] {},18 },19 _initializer: { nodeId: 1, backendNodeId: 1, nodeName: 'HTML' },20 },21 _page: Page {22 _channel: ChannelOwner {23 },24 _browserContext: BrowserContext {25 _channel: ChannelOwner {26 },27 },28 _workers: Map(0) {},29 _mainFrame: Frame {30 _channel: ChannelOwner {31 },

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const googleSearch = await page.$('input[name="q"]');7 await googleSearch.type('playwright');8 await googleSearch.press('Enter');9 await page.waitForSelector('h3');10 await page.waitForSelector('h3');11 const searchResults = await page.$$('h3');12 const firstResult = searchResults[0];13 const secondResult = firstResult.nextSibling();14 console.log(await secondResult.innerText());15 await browser.close();16})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 const input = await page.$('input[name="q"]');7 await input.type('Hello World!');8 await page.screenshot({ path: `example.png` });9 await browser.close();10})();11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch({ headless: false });14 const context = await browser.newContext();15 const page = await context.newPage();16 const input = await page.$('input[name="q"]');17 await input.type('Hello World!');18 await page.screenshot({ path: `example.png` });19 await browser.close();20})();21const { chromium } = require('playwright');22(async () => {23 const browser = await chromium.launch({ headless: false });24 const context = await browser.newContext();25 const page = await context.newPage();26 const input = await page.$('input[name="q"]');27 await input.type('Hello World!');28 await page.screenshot({ path: `example.png` });29 await browser.close();30})();31const { chromium } = require('playwright');32(async () => {33 const browser = await chromium.launch({ headless: false });34 const context = await browser.newContext();35 const page = await context.newPage();36 const input = await page.$('input[name="q"]');37 await input.type('Hello World!');38 await page.screenshot({ path: `example.png` });39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch({ headless: false });44 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Page } = require('playwright');2const { nextSibling } = require('playwright/lib/internal/page');3(async () => {4 const page = await browser.newPage();5 const nextSiblingElement = await nextSibling(page, '#id');6 console.log(nextSiblingElement);7})();8const { ElementHandle } = require('playwright');9const { nextSibling } = require('playwright/lib/internal/elementHandle');10(async () => {11 const page = await browser.newPage();12 const element = await page.$('#id');13 const nextSiblingElement = await nextSibling(element);14 console.log(nextSiblingElement);15})();16const { JSHandle } = require('playwright');17const { nextSibling } = require('playwright/lib/internal/jsHandle');18(async () => {19 const page = await browser.newPage();20 const element = await page.$('#id');21 const nextSiblingElement = await nextSibling(element);22 console.log(nextSiblingElement);23})();24const { Frame } = require('playwright');25const { nextSibling } = require('playwright/lib/internal/frame');26(async () => {27 const page = await browser.newPage();28 const nextSiblingElement = await nextSibling(page.mainFrame(), '#id');29 console.log(nextSiblingElement);30})();31const { Worker } = require('playwright');32const { nextSibling } = require('playwright/lib/internal/worker');33(async () => {34 const page = await browser.newPage();35 const nextSiblingElement = await nextSibling(page.serviceWorker(), '#id');36 console.log(nextSiblingElement);37})();38const { JSHandle } = require('playwright');39const { nextSibling } = require('playwright/lib/internal/jsHandle');40(async () => {41 const page = await browser.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 const ele = await page.$('input');4 const ele2 = await ele.nextSibling();5 await ele2.fill('test');6 await expect(ele2).toHaveValue('test');7});8 at ElementHandle._assertBoundingBox (/home/runner/work/playwright-test/playwright-test/node_modules/playwright/lib/cjs/pw_api.js:114:15)9 at ElementHandle._clickablePoint (/home/runner/work/playwright-test/playwright-test/node_modules/playwright/lib/cjs/pw_api.js:121:18)10 at ElementHandle._retryPointerAction (/home/runner/work/playwright-test/playwright-test/node_modules/playwright/lib/cjs/pw_api.js:140:28)11 at ElementHandle.click (/home/runner/work/playwright-test/playwright-test/node_modules/playwright/lib/cjs/pw_api.js:163:22)12 at ElementHandle.fill (/home/runner/work/playwright-test/playwright-test/node_modules/playwright/lib/cjs/pw_api.js:207:18)13 at test (/home/runner/work/playwright-test/playwright-test/test.js:9:8)14 at processTicksAndRejections (internal/process/task_queues.js:95:5)15 at async Test._runBody (/home/runner/work/playwright-test/playwright-test/node_modules/@playwright/test/lib/test.js:125:5)16 at async Test._run (/home/runner/work/playwright-test/playwright-test/node_modules/@playwright/test/lib/test.js:68:9)17 at async Runner._runTest (/home/runner/work/playwright-test/playwright-test/node_modules/@playwright/test/lib/runner.js:352:9)18 at ElementHandle._assertBoundingBox (/home/runner/work/playwright-test/playwright-test/node_modules/playwright/lib/cjs/pw_api.js:114:15)19 at ElementHandle._clickablePoint (/home/runner/work/playwright-test/playwright-test

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Page } = require('playwright');2const { getAttribute, getInnerText, getOuterHTML, getOuterText, getVisibleText, isDisabled, isEditable, isHidden, isEnabled, isFocused, isHiddenWithinTree, isHovered, isSelected, isVisible, isVisibleWithinViewport, waitForEnabled, waitForFocused, waitForHidden, waitForHiddenWithinTree, waitForHovered, waitForSelector, waitForStablePosition, waitForVisible, waitForVisibleWithinViewport } = require('playwright/lib/client/selectorEngine');3const { getBoundingBox, hover, scrollIntoViewIfNeeded, selectOption, setInputFiles, tap } = require('playwright/lib/client/elementHandle');4const { getAttribute, getInnerText, getOuterHTML, getOuterText, getVisibleText, isDisabled, isEditable, isHidden, isEnabled, isFocused, isHiddenWithinTree, isHovered, isSelected, isVisible, isVisibleWithinViewport, waitForEnabled, waitForFocused, waitForHidden, waitForHiddenWithinTree, waitForHovered, waitForSelector, waitForStablePosition, waitForVisible, waitForVisibleWithinViewport } = require('playwright/lib/client/elementHandle');5const { getAttribute, getInnerText, getOuterHTML, getOuterText, getVisibleText, isDisabled, isEditable, isHidden, isEnabled, isFocused, isHiddenWithinTree, isHovered, isSelected, isVisible, isVisibleWithinViewport, waitForEnabled, waitForFocused, waitForHidden, waitForHiddenWithinTree, waitForHovered, waitForSelector, waitForStablePosition, waitForVisible, waitForVisibleWithinViewport } = require('playwright/lib/client/elementHandle');6const { getAttribute, getInnerText, getOuterHTML, getOuterText, getVisibleText, isDisabled, isEditable, isHidden, isEnabled, isFocused, isHiddenWithinTree, isHovered, isSelected, isVisible, isVisibleWithinViewport, waitForEnabled, waitForFocused, waitForHidden, waitForHiddenWithinTree, waitForHovered, waitForSelector, waitForStablePosition, waitForVisible, waitForVisibleWithinViewport } = require('playwright/lib/client/elementHandle');7const { getAttribute, getInnerText, getOuterHTML, getOuterText, getVisibleText, isDisabled, isEditable, isHidden, isEnabled, isFocused, isHiddenWithinTree, isHovered, isSelected, isVisible, isVisibleWithinViewport, waitForEnabled, waitForFocused, waitForHidden, waitForHiddenWithinTree, waitForHovered, waitForSelector,

Full Screen

Playwright tutorial

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.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful