mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #1585 from node-red-hitachi/fix-HTML
fix HTML node not to reuse message object for multiple output messages
This commit is contained in:
		@@ -45,15 +45,16 @@ module.exports = function(RED) {
 | 
				
			|||||||
                            //if (node.ret === "val")  { pay2 = $(this).val(); }
 | 
					                            //if (node.ret === "val")  { pay2 = $(this).val(); }
 | 
				
			||||||
                            /* istanbul ignore else */
 | 
					                            /* istanbul ignore else */
 | 
				
			||||||
                            if (pay2) {
 | 
					                            if (pay2) {
 | 
				
			||||||
                                msg.payload = pay2;
 | 
					                                var new_msg = RED.util.cloneMessage(msg);
 | 
				
			||||||
                                msg.parts = {
 | 
					                                new_msg.payload = pay2;
 | 
				
			||||||
 | 
					                                new_msg.parts = {
 | 
				
			||||||
                                    id: msg._msgid,
 | 
					                                    id: msg._msgid,
 | 
				
			||||||
                                    index: index,
 | 
					                                    index: index,
 | 
				
			||||||
                                    count: count,
 | 
					                                    count: count,
 | 
				
			||||||
                                    type: "string",
 | 
					                                    type: "string",
 | 
				
			||||||
                                    ch: ""
 | 
					                                    ch: ""
 | 
				
			||||||
                                };
 | 
					                                };
 | 
				
			||||||
                                node.send(msg);
 | 
					                                node.send(new_msg);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        if (node.as === "single") {
 | 
					                        if (node.as === "single") {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -328,6 +328,32 @@ describe('html node', function() {
 | 
				
			|||||||
            });
 | 
					            });
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        it('should not reuse message', function(done) {
 | 
				
			||||||
 | 
					            fs.readFile(file, 'utf8', function(err, data) {
 | 
				
			||||||
 | 
					                var flow = [{id:"n1",type:"html",wires:[["n2"]],tag:"ul",ret:"text",as:"multi"},
 | 
				
			||||||
 | 
					                            {id:"n2", type:"helper"}];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                helper.load(htmlNode, flow, function() {
 | 
				
			||||||
 | 
					                    var n1 = helper.getNode("n1");
 | 
				
			||||||
 | 
					                    var n2 = helper.getNode("n2");
 | 
				
			||||||
 | 
					                    var prev_msg = undefined;
 | 
				
			||||||
 | 
					                    n2.on("input", function(msg) {
 | 
				
			||||||
 | 
					                        cnt++;
 | 
				
			||||||
 | 
					                        if (prev_msg == undefined) {
 | 
				
			||||||
 | 
					                            prev_msg = msg;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else {
 | 
				
			||||||
 | 
					                            msg.should.not.equal(prev_msg);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (cnt == 2) {
 | 
				
			||||||
 | 
					                            done();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    n1.receive({payload:data,topic: "bar"});
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user