Dashboard sipadu mbip
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.

aui-node-html5-debug.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. AUI.add('aui-node-html5', function(A) {
  2. /**
  3. * aui-node-html5 provides support for HTML shiv natively on the Alloy dom
  4. * methods. The HTML5 shiv just affects IE.
  5. *
  6. * @module aui-node
  7. * @submodule aui-node-html5
  8. */
  9. if (A.UA.ie) {
  10. /**
  11. * <p>An object that encapsulates util methods for HTML5 shiving.</p>
  12. * <h2>What is a "shiv"?</h1>
  13. * <p>To the world, a shiv is a slang term for a sharp object used as a
  14. * knife-like weapon. To Internet Explorer, a shiv is a script that, when
  15. * executed, forces the browser to recognize HTML5 elements.</p>
  16. *
  17. * @class A.HTML5
  18. */
  19. var HTML5 = A.namespace('HTML5'),
  20. DOM_create = A.DOM._create;
  21. if (!HTML5._fragHTML5Shived) {
  22. /**
  23. * A global DocumentFragment already HTML5 shived, for performance
  24. * reasons. (i.e., all nodes and its HTML5 children appended to this
  25. * fragment iherits the styles on IE).
  26. *
  27. * @property A.HTML._fragHTML5Shived
  28. * @type DocumentFragment (shived)
  29. * @protected
  30. */
  31. HTML5._fragHTML5Shived = YUI.AUI.html5shiv(
  32. A.config.doc.createDocumentFragment()
  33. );
  34. }
  35. A.mix(
  36. HTML5,
  37. {
  38. /**
  39. * Receives a <code>frag</code> and a HTML content. This method
  40. * shivs the HTML5 nodes appended to a Node or fragment which is not
  41. * on the document yet.
  42. *
  43. * @method IECreateFix
  44. * @param {Node | DocumentFragment} frag Fragment to be fixed.
  45. * @param {String} content HTML to be set (using innerHTML) on the <code>frag</code>.
  46. * @return {Node | DocumentFragment}
  47. */
  48. IECreateFix: function(frag, content) {
  49. var shivedFrag = HTML5._fragHTML5Shived;
  50. shivedFrag.appendChild(frag);
  51. frag.innerHTML = content;
  52. shivedFrag.removeChild(frag);
  53. return frag;
  54. },
  55. /**
  56. * AOP listener to the A.DOM._create method. This method
  57. * intercepts all the calls to the A.DOM._create and append the
  58. * generated fragment to <a
  59. * href="A.HTML5.html#property_A.HTML._fragHTML5Shived">A.HTML._fragHTML5Shived</a>,
  60. * this fixes the IE bug for painting the HTML5 nodes on the HTML
  61. * fragment.
  62. *
  63. * @method _doBeforeCreate
  64. * @param {String} html HTML content
  65. * @param {String} doc
  66. * @param {String} tag
  67. * @protected
  68. * @return {DocumentFragment}
  69. */
  70. _doBeforeCreate: function(html, doc, tag) {
  71. var createdFrag = DOM_create.apply(this, arguments);
  72. var shivedFrag = HTML5.IECreateFix(createdFrag, html);
  73. return new A.Do.Halt(null, shivedFrag);
  74. }
  75. }
  76. );
  77. A.Do.before(HTML5._doBeforeCreate, A.DOM, '_create', A.DOM);
  78. }
  79. }, '@VERSION@' ,{requires:['collection','aui-base']});