You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

innerHTML.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var alphabet = 'a!`=[]\\;\':"/<> &';
  2. var out = document.getElementById('out');
  3. var testContainer = document.getElementById('testContainer');
  4. function print(s) {
  5. out.value += s + "\n";
  6. }
  7. function testImage() {
  8. return testContainer.firstChild;
  9. }
  10. function test(input) {
  11. var count = 0;
  12. var oldInput, newInput;
  13. testContainer.innerHTML = "<img />";
  14. testImage().setAttribute("alt", input);
  15. print("------");
  16. print("Test input: " + input);
  17. do {
  18. oldInput = testImage().getAttribute("alt");
  19. var intermediate = testContainer.innerHTML;
  20. print("Render: " + intermediate);
  21. testContainer.innerHTML = intermediate;
  22. if (testImage() == null) {
  23. print("Image disappeared...");
  24. break;
  25. }
  26. newInput = testImage().getAttribute("alt");
  27. print("New value: " + newInput);
  28. count++;
  29. } while (count < 5 && newInput != oldInput);
  30. if (count == 5) {
  31. print("Failed to achieve fixpoint");
  32. }
  33. testContainer.innerHTML = "";
  34. }
  35. print("Go!");
  36. test("`` ");
  37. test("'' ");
  38. for (var i = 0; i < alphabet.length; i++) {
  39. for (var j = 0; j < alphabet.length; j++) {
  40. test(alphabet.charAt(i) + alphabet.charAt(j));
  41. }
  42. }
  43. // document.getElementById('out').textContent = alphabet;