attribute-no-space.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // non-strict: no error
  2. require(__dirname).test
  3. ( { xml : '<root attr1="first"attr2="second"/>'
  4. , expect :
  5. [ [ "attribute", { name: 'attr1', value: 'first' } ]
  6. , [ "attribute", { name: 'attr2', value: 'second' } ]
  7. , [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
  8. , [ "closetag", "root" ]
  9. ]
  10. , strict : false
  11. , opt : { lowercase: true }
  12. }
  13. )
  14. // strict: should give an error, but still parse
  15. require(__dirname).test
  16. ( { xml : '<root attr1="first"attr2="second"/>'
  17. , expect :
  18. [ [ "attribute", { name: 'attr1', value: 'first' } ]
  19. , [ "error", "No whitespace between attributes\nLine: 0\nColumn: 20\nChar: a" ]
  20. , [ "attribute", { name: 'attr2', value: 'second' } ]
  21. , [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
  22. , [ "closetag", "root" ]
  23. ]
  24. , strict : true
  25. , opt : { }
  26. }
  27. )
  28. // strict: other cases should still pass
  29. require(__dirname).test
  30. ( { xml : '<root attr1="first" attr2="second"/>'
  31. , expect :
  32. [ [ "attribute", { name: 'attr1', value: 'first' } ]
  33. , [ "attribute", { name: 'attr2', value: 'second' } ]
  34. , [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
  35. , [ "closetag", "root" ]
  36. ]
  37. , strict : true
  38. , opt : { }
  39. }
  40. )
  41. // strict: other cases should still pass
  42. require(__dirname).test
  43. ( { xml : '<root attr1="first"\nattr2="second"/>'
  44. , expect :
  45. [ [ "attribute", { name: 'attr1', value: 'first' } ]
  46. , [ "attribute", { name: 'attr2', value: 'second' } ]
  47. , [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
  48. , [ "closetag", "root" ]
  49. ]
  50. , strict : true
  51. , opt : { }
  52. }
  53. )
  54. // strict: other cases should still pass
  55. require(__dirname).test
  56. ( { xml : '<root attr1="first" attr2="second"/>'
  57. , expect :
  58. [ [ "attribute", { name: 'attr1', value: 'first' } ]
  59. , [ "attribute", { name: 'attr2', value: 'second' } ]
  60. , [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
  61. , [ "closetag", "root" ]
  62. ]
  63. , strict : true
  64. , opt : { }
  65. }
  66. )