[Pkg-javascript-commits] [ltx] 319/469: Cleaned up last of code, reinstated code style checks
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:03:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository ltx.
commit 50b8f99753e3cc737700c1fecbf3c890eeaf4fd0
Author: Lloyd Watkin <lloyd at evilprofessor.co.uk>
Date: Sun Feb 16 21:08:05 2014 +0000
Cleaned up last of code, reinstated code style checks
---
Gruntfile.js | 3 +--
lib/sax/sax_ltx.js | 22 ++++++++++++++--------
lib/sax/sax_node-xml.js | 1 +
test/element-test.js | 2 +-
4 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index d3ff78c..22b4afe 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -37,6 +37,5 @@ module.exports = function(grunt) {
// Configure tasks
grunt.registerTask('default', ['test'])
- grunt.registerTask('test', ['clean', 'vows', 'browserify'])
- //grunt.registerTask('test', ['clean', 'vows', 'jshint', 'browserify'])
+ grunt.registerTask('test', ['clean', 'vows', 'jshint', 'browserify'])
}
diff --git a/lib/sax/sax_ltx.js b/lib/sax/sax_ltx.js
index b71a455..e9a3e23 100644
--- a/lib/sax/sax_ltx.js
+++ b/lib/sax/sax_ltx.js
@@ -20,7 +20,20 @@ var SaxLtx = module.exports = function SaxLtx() {
var recordStart = 0
var attrName
+ this._handleTagOpening = function(endTag, tagName, attrs) {
+ if (!endTag) {
+ this.emit('startElement', tagName, attrs)
+ if (selfClosing) {
+ this.emit('endElement', tagName)
+ }
+ } else {
+ this.emit('endElement', tagName)
+ }
+ }
+
this.write = function(data) {
+ /* jshint -W071 */
+ /* jshint -W074 */
if (typeof data !== 'string') {
data = data.toString()
}
@@ -76,14 +89,7 @@ var SaxLtx = module.exports = function SaxLtx() {
break
case STATE_TAG:
if (c === 62 /* > */) {
- if (!endTag) {
- this.emit('startElement', tagName, attrs)
- if (selfClosing) {
- this.emit('endElement', tagName)
- }
- } else {
- this.emit('endElement', tagName)
- }
+ this._handleTagOpening(endTag, tagName, attrs)
tagName = undefined
attrs = undefined
endTag = undefined
diff --git a/lib/sax/sax_node-xml.js b/lib/sax/sax_node-xml.js
index 4a01440..138ec4e 100644
--- a/lib/sax/sax_node-xml.js
+++ b/lib/sax/sax_node-xml.js
@@ -12,6 +12,7 @@ var SaxNodeXML = module.exports = function SaxNodeXML() {
events.EventEmitter.call(this)
var self = this
this.parser = new xml.SaxParser(function(handler) {
+ /* jshint -W072 */
handler.onStartElementNS(function(elem, attrs, prefix, uri, namespaces) {
var i, attrsHash = {}
if (prefix) {
diff --git a/test/element-test.js b/test/element-test.js
index 4a7d759..1cc35fe 100644
--- a/test/element-test.js
+++ b/test/element-test.js
@@ -24,7 +24,7 @@ vows.describe('ltx').addBatch({
},
'serialize an element with text to entities': function() {
var e = new ltx.Element('e').t('1 < 2').root()
- assert.equal(e.toString(), '<e>1 < 2</e>')
+ assert.equal(e.toString(), '<e>1 < 2</e>')
},
'serialize an element with a number attribute': function() {
var e = new ltx.Element('e', { a: 23 })
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git
More information about the Pkg-javascript-commits
mailing list