nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jneen/parsimmon
Pull request #221 (2017-12-27 20:47:57)

fixes infinite loop bug in .many()
replaces #198 


Patch:
diff --git a/API.md b/API.md
index b587127..afc491d 100644
--- a/API.md
+++ b/API.md
@@ -694,6 +694,8 @@ Note: `parser.tie()` is usually used after `Parsimmon.seq(...parsers)` or `parse
 
 Expects `parser` zero or more times, and yields an array of the results.
 
+**NOTE:** If `parser`  is capable of parsing an empty string (i.e. `parser.parse("")` succeeds) then `parser.many()` will throw an error. Otherwise `parser.many()` would get stuck in an infinite loop.
+
 ## parser.times(n)
 
 Expects `parser` exactly `n` times, and yields an array of the results.
diff --git a/src/parsimmon.js b/src/parsimmon.js
index 26d262f..e604e19 100644
--- a/src/parsimmon.js
+++ b/src/parsimmon.js
@@ -403,6 +403,12 @@ _.many = function() {
     for (;;) {
       result = mergeReplies(self._(input, i), result);
       if (result.status) {
+        if (i === result.index) {
+          throw new Error(
+            "infinite loop detected in .many() parser --- calling .many() on " +
+              "a parser which can accept zero characters is usually the cause"
+          );
+        }
         i = result.index;
         accum.push(result.value);
       } else {


Test patch:
diff --git a/test/core/many.test.js b/test/core/many.test.js
index fa0a7ba..b657cfd 100644
--- a/test/core/many.test.js
+++ b/test/core/many.test.js
@@ -18,4 +18,17 @@ suite("many", function() {
     assert.equal(parser.parse("xy").value, "y");
     assert.equal(parser.parse("xxxxxy").value, "y");
   });
+
+  test("throws on parsers that accept zero characters", function() {
+    var parser = Parsimmon.regexp(/a*/).many();
+    assert.throws(function() {
+      parser.parse("a");
+    });
+    assert.throws(function() {
+      parser.parse("b");
+    });
+    assert.throws(function() {
+      parser.parse("");
+    });
+  });
 });
Repository: jneen/parsimmon
Pull request #232 (2018-03-21 19:48:39)

Fix issue where entire (very long) input is passed to bitSeq.
So I need help writing a test that actually creates the problem I have fixed.  In the binary parser I have constructed, when the parser runs, I am getting the entire input to bitSeq, when it's supposed to just operate on a slice of the input (when embedded as part of a large parsing context).  I have fixed this issue, but I cannot seem to replicate it in a small test to prove it's an issue.

Can someone help me construct a proper test that will fail without this change?


Patch:
diff --git a/src/parsimmon.js b/src/parsimmon.js
index f3ebafa..d199d6b 100644
--- a/src/parsimmon.js
+++ b/src/parsimmon.js
@@ -129,11 +129,12 @@ function bitSeq(alignments) {
   }
 
   return new Parsimmon(function(input, i) {
-    if (bytes + i > input.length) {
+    var newPos = bytes + i;
+    if (newPos > input.length) {
       return makeFailure(i, bytes.toString() + " bytes");
     }
     return makeSuccess(
-      i + bytes,
+      newPos,
       reduce(
         function(acc, bits) {
           var state = consumeBitsFromBuffer(bits, acc.buf);
@@ -142,7 +143,7 @@ function bitSeq(alignments) {
             buf: state.buf
           };
         },
-        { coll: [], buf: input },
+        { coll: [], buf: input.slice(i, newPos) },
         alignments
       ).coll
     );


Test patch:
diff --git a/test/core/bitSeq.test.js b/test/core/bitSeq.test.js
index 9949d6a..2940c84 100644
--- a/test/core/bitSeq.test.js
+++ b/test/core/bitSeq.test.js
@@ -42,4 +42,15 @@ describe("bitSeq", function() {
       }, /buffer global/i);
     });
   });
+
+  context("We are bitSeq'ing not at the beginning.", function() {
+    it("Should still work.", function() {
+      var b = Buffer.from([0x10, 0xff, 0xff]);
+      var p = Parsimmon.seqObj(Parsimmon.any, [
+        "data",
+        Parsimmon.Binary.bitSeq([3, 5, 5, 3])
+      ]);
+      assert.deepEqual(p.parse(b).value.data, [7, 31, 31, 7]);
+    });
+  });
 });
Repository: jneen/parsimmon
Pull request #235 (2018-04-04 18:38:31)

Prefix keys in seqObj's seenKeys to avoid collisions
Otherwise, seqObj will fail for the keys in `Object.getOwnPropertyNames(Object.prototype)`, the most likely collision being "constructor".

An alternate implementation strategy is `Object.create(null)`, but it's not supported on IE <9, and is not possible to polyfill.


Patch:
diff --git a/src/parsimmon.js b/src/parsimmon.js
index d199d6b..a809762 100644
--- a/src/parsimmon.js
+++ b/src/parsimmon.js
@@ -167,7 +167,7 @@ function bitSeqObj(namedAlignments) {
       }
       assertString(pair[0]);
       assertNumber(pair[1]);
-      if (seenKeys[pair[0]]) {
+      if (Object.prototype.hasOwnProperty.call(seenKeys, pair[0])) {
         throw new Error("duplicate key in bitSeqObj: " + pair[0]);
       }
       seenKeys[pair[0]] = true;
@@ -455,7 +455,7 @@ function seqObj() {
         p.length === 2 && typeof p[0] === "string" && isParser(p[1]);
       if (isWellFormed) {
         var key = p[0];
-        if (seenKeys[key]) {
+        if (Object.prototype.hasOwnProperty.call(seenKeys, key)) {
           throw new Error("seqObj: duplicate key " + key);
         }
         seenKeys[key] = true;


Test patch:
diff --git a/test/core/bitSeqObj.test.js b/test/core/bitSeqObj.test.js
index 0d152fa..ac53e3a 100644
--- a/test/core/bitSeqObj.test.js
+++ b/test/core/bitSeqObj.test.js
@@ -85,4 +85,10 @@ describe("bitSeqObj", function() {
       }, /buffer global/i);
     });
   });
+
+  test("accepts 'constructor' as a key", function() {
+    var b = Buffer.from([0xff]);
+    var p = Parsimmon.Binary.bitSeqObj([["constructor", 8]]);
+    assert.deepEqual(p.parse(b).value, { constructor: 255 });
+  });
 });
diff --git a/test/core/seqObj.test.js b/test/core/seqObj.test.js
index 81e2b65..d5aca8a 100644
--- a/test/core/seqObj.test.js
+++ b/test/core/seqObj.test.js
@@ -73,4 +73,12 @@ suite("Parsimmon.seqObj", function() {
       Parsimmon.seqObj(0);
     });
   });
+
+  test("accepts 'constructor' as a key", function() {
+    var parser = Parsimmon.seqObj(["constructor", Parsimmon.of(1)]);
+    var result = parser.tryParse("");
+    assert.deepStrictEqual(result, {
+      constructor: 1
+    });
+  });
 });
Repository: jneen/parsimmon
Pull request #324 (2021-06-18 04:54:57)

fix: Fix line number double counting bug when parsing optional newlines
Ran into a very subtle bug in my [previous PR](https://github.com/jneen/parsimmon/pull/321). Basically, when parsing a new line and then an optional newline there is a double count of the line number because of the order of the branches in the walking algorithm I wrote. Flipping the order fixes it.

I added a regression test, without this change you will see `line: 3` in `end`.

- [x] I have run `npm run lint:fix` to ensure Prettier and ESLint have passed
- [x] Coveralls bot has replied that the tests pass with 100% code coverage (`npm test`)
- [x] I have updated `CHANGELOG.md` (and `API.md` if this is an API change)


wavebeem: Looks great, nice catch! I'll merge and release it this weekend and @ you when it goes out :) Thanks

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7f3381..e07b8d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.18.0 (2021-06-17)
+
+- Fixes a bug in the line/column number tracking when parsing optional newlines
+  
 ## 1.17.0 (2021-04-18)
 
 - Improves the performance of line/column number tracking (contributed by @brendo-m)
diff --git a/src/parsimmon.js b/src/parsimmon.js
index 38fdb4d..80e2987 100644
--- a/src/parsimmon.js
+++ b/src/parsimmon.js
@@ -390,13 +390,6 @@ function makeLineColumnIndex(input, i) {
   var lineStart = 0;
   var j = i;
   while (j >= 0) {
-    if (input.charAt(j) === "\n") {
-      newLines++;
-      // lineStart === 0 when this is the first new line we have found
-      if (lineStart === 0) {
-        lineStart = j + 1;
-      }
-    }
     if (j in inputIndex) {
       prevLine = inputIndex[j].line;
       // lineStart === 0 when we haven't found a new line on the walk
@@ -407,6 +400,13 @@ function makeLineColumnIndex(input, i) {
       }
       break;
     }
+    if (input.charAt(j) === "\n") {
+      newLines++;
+      // lineStart === 0 when this is the first new line we have found
+      if (lineStart === 0) {
+        lineStart = j + 1;
+      }
+    }
     j--;
   }
 


Test patch:
diff --git a/test/core/mark.test.js b/test/core/mark.test.js
index aac7699..db06bd3 100644
--- a/test/core/mark.test.js
+++ b/test/core/mark.test.js
@@ -19,3 +19,24 @@ it("mark", function() {
     end: { offset: 3, line: 2, column: 3 }
   });
 });
+
+it("should correctly report line number when parsing optional newlines", function() {
+  var parser = Parsimmon.seq(
+    Parsimmon.newline,
+    Parsimmon.newline.many()
+  ).mark();
+
+  assert.deepEqual(parser.parse("\n").value, {
+    start: {
+      column: 0,
+      line: 2,
+      offset: 0
+    },
+    end: {
+      column: 1,
+      line: 2,
+      offset: 1
+    },
+    value: ["\n", []]
+  });
+});
Repository: jneen/parsimmon
Pull request #333 (2021-12-20 03:02:57)

Issue 329
Fixes #329

- [x] I have run `npm run lint:fix` to ensure Prettier and ESLint have passed
- [x] Coveralls bot has replied that the tests pass with 100% code coverage (`npm test`)
- [x] I have updated `CHANGELOG.md` (and `API.md` if this is an API change)



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00df567..91c29cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.18.1 (2021-12-19)
+
+- Fixes a bug in the line/column number tracking for Mac OS 9 linebreaks
+
 ## 1.18.0 (2021-06-19)
 
 - Fixes a bug in the line/column number tracking when parsing optional newlines
diff --git a/src/parsimmon.js b/src/parsimmon.js
index 80e2987..9f134f7 100644
--- a/src/parsimmon.js
+++ b/src/parsimmon.js
@@ -400,7 +400,13 @@ function makeLineColumnIndex(input, i) {
       }
       break;
     }
-    if (input.charAt(j) === "\n") {
+
+    if (
+      // Unix LF (\n) or Windows CRLF (\r\n) line ending
+      input.charAt(j) === "\n" ||
+      // Old Mac CR (\r) line ending
+      (input.charAt(j) === "\r" && input.charAt(j + 1) !== "\n")
+    ) {
       newLines++;
       // lineStart === 0 when this is the first new line we have found
       if (lineStart === 0) {


Test patch:
diff --git a/test/core/mark.test.js b/test/core/mark.test.js
index db06bd3..dfaf89d 100644
--- a/test/core/mark.test.js
+++ b/test/core/mark.test.js
@@ -20,23 +20,31 @@ it("mark", function() {
   });
 });
 
-it("should correctly report line number when parsing optional newlines", function() {
-  var parser = Parsimmon.seq(
-    Parsimmon.newline,
-    Parsimmon.newline.many()
-  ).mark();
+["\n", "\r", "\r\n"].forEach(function(eol) {
+  it(
+    "should correctly report line number when parsing optional " +
+      JSON.stringify(eol),
+    function() {
+      var parser = Parsimmon.seq(
+        Parsimmon.string("foo"),
+        Parsimmon.newline
+      ).mark();
 
-  assert.deepEqual(parser.parse("\n").value, {
-    start: {
-      column: 0,
-      line: 2,
-      offset: 0
-    },
-    end: {
-      column: 1,
-      line: 2,
-      offset: 1
-    },
-    value: ["\n", []]
-  });
+      var input = "foo" + eol;
+
+      assert.deepEqual(parser.parse(input).value, {
+        start: {
+          column: 1,
+          line: 1,
+          offset: 0
+        },
+        end: {
+          column: 1,
+          line: 2,
+          offset: input.length
+        },
+        value: ["foo", eol]
+      });
+    }
+  );
 });
Repository: axios/axios
Pull request #6401 (2024-05-18 22:36:45)

fix(fetch): fix headers getting from a stream response;


Patch:
diff --git a/lib/adapters/fetch.js b/lib/adapters/fetch.js
index d053e57..91af945 100644
--- a/lib/adapters/fetch.js
+++ b/lib/adapters/fetch.js
@@ -169,7 +169,7 @@ export default isFetchSupported && (async (config) => {
     if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
       const options = {};
 
-      Object.getOwnPropertyNames(response).forEach(prop => {
+      ['status', 'statusText', 'headers'].forEach(prop => {
         options[prop] = response[prop];
       });
 


Test patch:
diff --git a/test/unit/adapters/fetch.js b/test/unit/adapters/fetch.js
index 1d8498e..546fa2c 100644
--- a/test/unit/adapters/fetch.js
+++ b/test/unit/adapters/fetch.js
@@ -380,4 +380,17 @@ describe('supports fetch with nodejs', function () {
       assert.strictEqual(err.cause && err.cause.code, 'ENOTFOUND');
     }
   });
+
+  it('should get response headers', async () => {
+    server = await startHTTPServer((req, res) => {
+      res.setHeader('foo', 'bar');
+      res.end(req.url)
+    });
+
+    const {headers} = await fetchAxios.get('/', {
+      responseType: 'stream'
+    });
+
+    assert.strictEqual(headers.get('foo'), 'bar');
+  });
 });
Repository: axios/axios
Pull request #6615 (2024-09-27 21:59:11)

fix: update aborted error message for clarity
# Description
Updates the axios error message when an aborted event from the stream is encountered. The error message is especially egregious when `maxContentLength` is defaulted to `-1`. 

This serves to make the message more clear but doesn't attempt to fix underlying causes of any aborted signal.

# Background
I recently encountered this message from a service who made an axios request sourced from a socket.io connection. When that socket connection was killed, an abort signal was generated that caused axios to abort the request. But the message displayed made the situation quite confusing.

# Related Issues
The following are where discussions have been had around the overall confusing nature of the error.
- https://github.com/axios/axios/issues/6437
- https://github.com/axios/axios/issues/6455
- https://github.com/axios/axios/issues/4806


Patch:
diff --git a/lib/adapters/http.js b/lib/adapters/http.js
index d465851..70cb5cf 100755
--- a/lib/adapters/http.js
+++ b/lib/adapters/http.js
@@ -569,7 +569,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
           }
 
           const err = new AxiosError(
-            'maxContentLength size of ' + config.maxContentLength + ' exceeded',
+            'stream has been aborted',
             AxiosError.ERR_BAD_RESPONSE,
             config,
             lastRequest


Test patch:
diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js
index 32889ba..6d80ad6 100644
--- a/test/unit/adapters/http.js
+++ b/test/unit/adapters/http.js
@@ -1642,7 +1642,7 @@ describe('supports http with nodejs', function () {
         assert.strictEqual(success, false, 'request should not succeed');
         assert.strictEqual(failure, true, 'request should fail');
         assert.strictEqual(error.code, 'ERR_BAD_RESPONSE');
-        assert.strictEqual(error.message, 'maxContentLength size of -1 exceeded');
+        assert.strictEqual(error.message, 'stream has been aborted');
         done();
       }).catch(done);
     });
Repository: gammazero/nexus
Pull request #213 (2019-12-30 21:33:25)

Converting nil to List or Dict is OK
Replaces PR #209 


Patch:
diff --git a/client/client.go b/client/client.go
index 1659745..7926682 100644
--- a/client/client.go
+++ b/client/client.go
@@ -701,6 +701,13 @@ func (c *Client) SendProgress(ctx context.Context, args wamp.List, kwArgs wamp.D
 	c.sess.Unlock()
 
 	if !ok {
+		// progGate value may have been removed if session was disconnected.
+		select {
+		case <-c.Done():
+			return ErrNotConn
+		default:
+		}
+
 		// Caller is not accepting progressive results or call canceled.
 		return ErrCallerNoProg
 	}
diff --git a/wamp/convert.go b/wamp/convert.go
index fe43e28..5ab6bbf 100644
--- a/wamp/convert.go
+++ b/wamp/convert.go
@@ -94,6 +94,9 @@ func AsBool(v interface{}) (bool, bool) {
 
 // AsDict is an extended type assertion for Dict.
 func AsDict(v interface{}) (Dict, bool) {
+	if v == nil {
+		return nil, true
+	}
 	n := NormalizeDict(v)
 	return n, n != nil
 }
@@ -105,6 +108,8 @@ func AsList(v interface{}) (List, bool) {
 		return v, true
 	case []interface{}:
 		return List(v), true
+	case nil:
+		return nil, true
 	}
 	val := reflect.ValueOf(v)
 	if val.Kind() != reflect.Slice {


Test patch:
diff --git a/wamp/convert_test.go b/wamp/convert_test.go
index f32dd62..3e88075 100644
--- a/wamp/convert_test.go
+++ b/wamp/convert_test.go
@@ -34,8 +34,8 @@ func TestAsList(t *testing.T) {
 	if l, ok = AsList(numConv); ok || l != nil {
 		t.Error(shouldFailMsg)
 	}
-	if l, ok = AsList(nil); ok || l != nil {
-		t.Error(shouldFailMsg)
+	if l, ok = AsList(nil); !ok && l == nil {
+		t.Error(failMsg)
 	}
 }
 
@@ -53,8 +53,8 @@ func TestAsDict(t *testing.T) {
 	if d, ok = AsDict(interface{}(numConv)); ok || d != nil {
 		t.Error(shouldFailMsg)
 	}
-	if d, ok = AsDict(nil); ok || d != nil {
-		t.Error(shouldFailMsg)
+	if d, ok = AsDict(nil); !ok && d == nil {
+		t.Error(failMsg)
 	}
 }
Repository: Rich-Harris/buble
Pull request #2 (2017-09-23 17:29:33)

Allow truthy dash-cased props
*moved from https://gitlab.com/Rich-Harris/buble/merge_requests/122*

- Add `true` to output if contains dashed and non-value
- Refactor if/else into named functions
- data-attribute -> any dash-cased prop
- Add test


Patch:
diff --git a/src/program/types/JSXAttribute.js b/src/program/types/JSXAttribute.js
index e5645db..9e21293 100644
--- a/src/program/types/JSXAttribute.js
+++ b/src/program/types/JSXAttribute.js
@@ -1,19 +1,19 @@
 import Node from '../Node.js';
 
-const IS_DATA_ATTRIBUTE = /-/;
+const hasDashes = val => /-/.test(val);
+
+const formatKey = key => hasDashes(key) ? `'${key}'` : key;
+
+const formatVal = val => val ? '' : 'true';
 
 export default class JSXAttribute extends Node {
 	transpile ( code, transforms ) {
-		if ( this.value ) {
-			code.overwrite( this.name.end, this.value.start, ': ' );
-		} else {
-			// tag without value
-			code.overwrite( this.name.start, this.name.end, `${this.name.name}: true` );
-		}
+		const { start, name }	= this.name;
+
+		// Overwrite equals sign if value is present.
+		const end = this.value ? this.value.start : this.name.end;
 
-		if ( IS_DATA_ATTRIBUTE.test( this.name.name ) ) {
-			code.overwrite( this.name.start, this.name.end, `'${this.name.name}'` );
-		}
+		code.overwrite( start, end, `${formatKey(name)}: ${formatVal(this.value)}` );
 
 		super.transpile( code, transforms );
 	}


Test patch:
diff --git a/test/samples/jsx.js b/test/samples/jsx.js
index 9b18a5a..74368ea 100644
--- a/test/samples/jsx.js
+++ b/test/samples/jsx.js
@@ -224,4 +224,15 @@ module.exports = [
 		`
 	},
 
+	{
+		description: 'handles dash-cased value-less props',
+
+		input: `
+			<Thing data-foo></Thing>
+		`,
+		output: `
+			React.createElement( Thing, { 'data-foo': true })
+		`
+	},
+
 ];
Repository: Rich-Harris/buble
Pull request #5 (2017-09-23 17:32:59)

Maranomynet/buble feature/jsx pragma comments
*moved from https://gitlab.com/Rich-Harris/buble/merge_requests/119*


Patch:
diff --git a/package.json b/package.json
index 9915924..a65fbb3 100644
--- a/package.json
+++ b/package.json
@@ -63,6 +63,7 @@
     "acorn-jsx": "^3.0.1",
     "acorn-object-spread": "^1.0.0",
     "chalk": "^1.1.3",
+    "vlq": "0.2.1",
     "magic-string": "^0.14.0",
     "minimist": "^1.2.0",
     "os-homedir": "^1.0.1",
diff --git a/src/index.js b/src/index.js
index 56edecb..445385f 100644
--- a/src/index.js
+++ b/src/index.js
@@ -46,17 +46,25 @@ export function target ( target ) {
 
 export function transform ( source, options = {} ) {
 	let ast;
+	let jsx = null;
 
 	try {
 		ast = parse( source, {
 			ecmaVersion: 7,
 			preserveParens: true,
 			sourceType: 'module',
+			onComment: (block, text) => {
+				if ( !jsx ) {
+					let match = /@jsx\s+([^\s]+)/.exec( text );
+					if ( match ) jsx = match[1];
+				}
+			},
 			plugins: {
 				jsx: true,
 				objectSpread: true
 			}
 		});
+		options.jsx = jsx || options.jsx;
 	} catch ( err ) {
 		err.snippet = getSnippet( source, err.loc );
 		err.toString = () => `${err.name}: ${err.message}\n${err.snippet}`;


Test patch:
diff --git a/test/cli/supports-jsx-pragma-comment/command.sh b/test/cli/supports-jsx-pragma-comment/command.sh
new file mode 100644
index 0000000..9385984
--- /dev/null
+++ b/test/cli/supports-jsx-pragma-comment/command.sh
@@ -0,0 +1,1 @@
+buble input.js -o actual/output.js --jsx NotReact.createElement
diff --git a/test/cli/supports-jsx-pragma-comment/expected/output.js b/test/cli/supports-jsx-pragma-comment/expected/output.js
new file mode 100644
index 0000000..db30e6f
--- /dev/null
+++ b/test/cli/supports-jsx-pragma-comment/expected/output.js
@@ -0,0 +1,2 @@
+/* @jsx customPragma */
+var div = customPragma( 'div', null, "Hello" )
diff --git a/test/cli/supports-jsx-pragma-comment/input.js b/test/cli/supports-jsx-pragma-comment/input.js
new file mode 100644
index 0000000..356d281
--- /dev/null
+++ b/test/cli/supports-jsx-pragma-comment/input.js
@@ -0,0 +1,2 @@
+/* @jsx customPragma */
+var div = <div>Hello</div>
diff --git a/test/samples/jsx.js b/test/samples/jsx.js
index 74368ea..6d01952 100644
--- a/test/samples/jsx.js
+++ b/test/samples/jsx.js
@@ -224,6 +224,32 @@ module.exports = [
 		`
 	},
 
+	{
+		description: 'supports /* @jsx customPragma */ directives (#195)',
+		input: `
+			/* @jsx customPragma */
+			var div = <div>Hello</div>
+		`,
+		output: `
+			/* @jsx customPragma */
+			var div = customPragma( 'div', null, "Hello" )
+		`
+	},
+
+	{
+		description: 'ignores subsequent /* @jsx customPragma */ directives (#195)',
+		input: `
+			/* @jsx customPragma */
+			/* @jsx customPragmaWannabe */
+			var div = <div>Hello</div>
+		`,
+		output: `
+			/* @jsx customPragma */
+			/* @jsx customPragmaWannabe */
+			var div = customPragma( 'div', null, "Hello" )
+		`
+	},
+
 	{
 		description: 'handles dash-cased value-less props',
 
@@ -233,6 +259,5 @@ module.exports = [
 		output: `
 			React.createElement( Thing, { 'data-foo': true })
 		`
-	},
-
+	}
 ];
Repository: Rich-Harris/buble
Pull request #6 (2017-09-23 17:46:42)

handle JSX with no space between attributes (#178)
*moved from https://gitlab.com/Rich-Harris/buble/merge_requests/117*


Patch:
diff --git a/src/program/types/JSXOpeningElement.js b/src/program/types/JSXOpeningElement.js
index 1147b7b..2c77295 100644
--- a/src/program/types/JSXOpeningElement.js
+++ b/src/program/types/JSXOpeningElement.js
@@ -28,7 +28,10 @@ export default class JSXOpeningElement extends Node {
 				const attr = this.attributes[i];
 
 				if ( i > 0 ) {
-					code.overwrite( c, attr.start, ', ' );
+					if ( attr.start === c )
+						code.insertRight( c, ', ' );
+					else
+						code.overwrite( c, attr.start, ', ' );
 				}
 
 				if ( hasSpread && attr.type !== 'JSXSpreadAttribute' ) {


Test patch:
diff --git a/test/samples/jsx.js b/test/samples/jsx.js
index 6d01952..fe1b2fa 100644
--- a/test/samples/jsx.js
+++ b/test/samples/jsx.js
@@ -224,6 +224,17 @@ module.exports = [
 		`
 	},
 
+	{
+		description: 'fix no space between JSXOpeningElement attributes (#178)',
+
+		input: `
+			<div style={{color:'#000000'}}className='content'/>
+		`,
+		output: `
+			React.createElement( 'div', { style: {color:'#000000'}, className: 'content' })
+		`
+	},
+
 	{
 		description: 'supports /* @jsx customPragma */ directives (#195)',
 		input: `