test40.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 040</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "en-us": "FORCEHYPHENOPOLY"
  10. },
  11. setup: {
  12. selectors: {
  13. ".class1": {
  14. hyphen: "·"
  15. },
  16. ".class2": {
  17. hyphen: "·",
  18. mixedCase: false
  19. }
  20. }
  21. },
  22. handleEvent: {
  23. hyphenopolyEnd: function (e) {
  24. assert();
  25. }
  26. }
  27. };
  28. </script>
  29. <script src="../Hyphenopoly_Loader.js"></script>
  30. <script>
  31. function assert() {
  32. var tests = 2;
  33. var i = 1;
  34. var test = "";
  35. var ref = "";
  36. var result = true;
  37. while (i <= tests) {
  38. test = document.getElementById("test" + i).innerHTML;
  39. ref = document.getElementById("ref" + i).innerHTML;
  40. if (test === ref) {
  41. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  42. result = result && true;
  43. } else {
  44. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  45. result = false;
  46. }
  47. i += 1;
  48. }
  49. if (parent != window) {
  50. parent.postMessage(JSON.stringify({
  51. desc: document.getElementById("desc").innerHTML,
  52. index: 40,
  53. result: (result ? "passed" : "failed")
  54. }), window.location.href);
  55. }
  56. }
  57. if (!Hyphenopoly) {
  58. document.addEventListener("DOMContentLoaded", function() {
  59. assert();
  60. });
  61. }
  62. </script>
  63. <style type="text/css">
  64. body {
  65. width:50%;
  66. margin-left:25%;
  67. margin-right:25%;
  68. }
  69. .test {
  70. background-color: #D8E2F9;
  71. }
  72. .ref {
  73. background-color: #FEEFC0;
  74. }
  75. .hyphenate {
  76. hyphens: auto;
  77. -ms-hyphens: auto;
  78. -moz-hyphens: auto;
  79. -webkit-hyphens: auto;
  80. }
  81. </style>
  82. </head>
  83. <body>
  84. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test39.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test41.html">Next&nbsp;&rarr;</a></div>
  85. <h1>Test 040</h1>
  86. <p id="desc">Handle mixed cased words</p>
  87. <div id="result"></div>
  88. <hr>
  89. <h2>1: hyphenate mixed case</h2>
  90. <p id="test1" class="test class1" lang="en-us">Hyphenation algorithm camelCase</p>
  91. <p id="ref1" class="ref" lang="en-us">Hy·phen·ation al·go·rithm camel·Case</p>
  92. <h2>2: don't hyphenate mixed case</h2>
  93. <p id="test2" class="test class2" lang="en-us">Hyphenation algorithm camelCase</p>
  94. <p id="ref2" class="ref" lang="en-us">Hyphenation al·go·rithm camelCase</p>
  95. <hr>
  96. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  97. </body>
  98. </html>