nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: bem/bh
Pull request #143 (2015-04-24 10:40:04)

trim cls when proccess it into html


Patch:
diff --git a/lib/bh.js b/lib/bh.js
index 1d9e3c1..22afe64 100644
--- a/lib/bh.js
+++ b/lib/bh.js
@@ -1038,7 +1038,7 @@ BH.prototype = {
             }
 
             if (json.cls) {
-                cls = (cls ? cls + ' ' : '') + attrEscape(json.cls);
+                cls = (cls ? cls + ' ' : '') + attrEscape(json.cls).trim();
             }
 
             var content, tag = (json.tag || 'div');


Test patch:
diff --git a/test/test.cls.js b/test/test.cls.js
index e1b477e..782df78 100644
--- a/test/test.cls.js
+++ b/test/test.cls.js
@@ -18,6 +18,12 @@ describe('ctx.cls()', function() {
         });
         bh.apply({ block: 'button' }).should.equal('<div class="button btn"></div>');
     });
+    it('should trim cls', function() {
+        bh.match('button', function(ctx) {
+            ctx.cls('  btn  ');
+        });
+        bh.apply({ block: 'button' }).should.equal('<div class="button btn"></div>');
+    });
     it('should escape cls', function() {
         bh.match('button', function(ctx) {
             ctx.cls('url="a=b&c=d"');
Repository: bem/bh
Pull request #166 (2015-12-04 20:17:34)

fix: raw html output


Patch:
diff --git a/lib/bh.js b/lib/bh.js
index 7148887..2f8e928 100644
--- a/lib/bh.js
+++ b/lib/bh.js
@@ -904,7 +904,7 @@ BH.prototype = {
         } else {
             var isBEM = json.bem !== false;
             if (typeof json.tag !== 'undefined' && !json.tag) {
-                return json.html || json.content ? this.toHtml(json.content) : '';
+                return json.html || (json.content ? this.toHtml(json.content) : '');
             }
             if (json.mix && !Array.isArray(json.mix)) {
                 json.mix = [json.mix];


Test patch:
diff --git a/test/test.html.js b/test/test.html.js
index 966fb3d..b1092f7 100644
--- a/test/test.html.js
+++ b/test/test.html.js
@@ -7,6 +7,10 @@ describe('ctx.html()', function() {
         bh = new BH();
     });
 
+    it('should prefer html over content', function() {
+        bh.apply({ tag: false, html: 'Hello', content: 'Bye' }).should.equal('Hello');
+    });
+
     it('should return bemjson html', function() {
         bh.match('button', function(ctx) {
             ctx.html().should.equal('Hello');
diff --git a/test/test.js.js b/test/test.js.js
index 8ea7400..f1a5e29 100644
--- a/test/test.js.js
+++ b/test/test.js.js
@@ -47,7 +47,7 @@ describe('ctx.js()', function() {
         bh.match('button', function(ctx) {
             ctx.js({ a: 1 });
         });
-        bh.apply({ block: 'button', js: true }).should.equal('<div class="button i-bem" onclick=\'return {"button":{"a":1}}\'></div>');
+        bh.apply({ block: 'button', js: true }).should.equal('<div class="button i-bem" onclick="return {&quot;button&quot;:{&quot;a&quot;:1}}"></div>');
     });
 
     it('should not override later declarations #1', function() {
Repository: webpack/webpack
Pull request #6055 (2017-12-02 00:53:02)

Improve Parser to recognize 'new Foo(...)' type expressions
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. -->

**What kind of change does this PR introduce?**
Improves Parser to recognize 'new Foo(...)' type expressions
<!-- E.g. a bugfix, feature, refactoring, build related change, etc… -->

**Did you add tests for your changes?**
Yes
<!-- Note that we won't merge your changes if you don't add tests -->

**If relevant, link to documentation update:**

<!-- Link PR from webpack/webpack.js.org here, or N/A -->

**Summary**
Please see #6054 
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
<!-- Try to link to an open issue for more information. -->

**Does this PR introduce a breaking change?**
No
<!-- If this PR introduces a breaking change, please describe the impact and a migration path for existing applications. -->

**Other information**



Patch:
diff --git a/lib/Parser.js b/lib/Parser.js
index 7a327d337..b5645cf1b 100644
--- a/lib/Parser.js
+++ b/lib/Parser.js
@@ -1047,6 +1047,14 @@ class Parser extends Tapable {
 	}
 
 	walkNewExpression(expression) {
+		const callee = this.evaluateExpression(expression.callee);
+		if(callee.isIdentifier()) {
+			const result = this.applyPluginsBailResult("new " + callee.identifier, expression);
+			if(result === true) {
+				return;
+			}
+		}
+
 		this.walkExpression(expression.callee);
 		if(expression.arguments)
 			this.walkExpressions(expression.arguments);


Test patch:
diff --git a/test/Parser.unittest.js b/test/Parser.unittest.js
index 3b74d07d7..41435d2be 100644
--- a/test/Parser.unittest.js
+++ b/test/Parser.unittest.js
@@ -191,6 +191,13 @@ describe("Parser", () => {
 				ijksub: ["test"]
 			}
 		],
+		"new Foo(...)": [
+			function() {
+				new xyz("membertest");
+			}, {
+				xyz: ["membertest"]
+			}
+		],
 	};
 
 	Object.keys(testCases).forEach((name) => {
@@ -237,6 +244,11 @@ describe("Parser", () => {
 				testParser.state.expressions.push(expr.name);
 				return true;
 			});
+			testParser.plugin("new xyz", (expr) => {
+				if(!testParser.state.xyz) testParser.state.xyz = [];
+				testParser.state.xyz.push(testParser.parseString(expr.arguments[0]));
+				return true;
+			});
 			const actual = testParser.parse(source);
 			should.strictEqual(typeof actual, "object");
 			actual.should.be.eql(state);