{"action":"created","issue":{"url":"https://api.github.com/repos/bpmn-io/bpmn-js/issues/536","repository_url":"https://api.github.com/repos/bpmn-io/bpmn-js","labels_url":"https://api.github.com/repos/bpmn-io/bpmn-js/issues/536/labels{/name}","comments_url":"https://api.github.com/repos/bpmn-io/bpmn-js/issues/536/comments","events_url":"https://api.github.com/repos/bpmn-io/bpmn-js/issues/536/events","html_url":"https://github.com/bpmn-io/bpmn-js/issues/536","id":152969018,"number":536,"title":"Rules added via RuleProvider ignored by Connect","user":{"login":"philippfromme","id":7633572,"avatar_url":"https://avatars.githubusercontent.com/u/7633572?v=3","gravatar_id":"","url":"https://api.github.com/users/philippfromme","html_url":"https://github.com/philippfromme","followers_url":"https://api.github.com/users/philippfromme/followers","following_url":"https://api.github.com/users/philippfromme/following{/other_user}","gists_url":"https://api.github.com/users/philippfromme/gists{/gist_id}","starred_url":"https://api.github.com/users/philippfromme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philippfromme/subscriptions","organizations_url":"https://api.github.com/users/philippfromme/orgs","repos_url":"https://api.github.com/users/philippfromme/repos","events_url":"https://api.github.com/users/philippfromme/events{/privacy}","received_events_url":"https://api.github.com/users/philippfromme/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-04T09:29:33Z","updated_at":"2016-05-09T06:05:34Z","closed_at":null,"body":"### Problem\r\n\r\nRules added by diagram-js's `RuleProvider` are irgnored when using diagram-js's `Connect` to create a new connection. By calling\r\n\r\n```\r\nmodeling.connect(source, target);\r\n```\r\n\r\nwithout the third parameter set the object returned from my rule is effectively thrown away which causes bpmn-js's `Modeling` to always use a default connection or the one provided by bpmn-js's `BpmnRules`.\r\n\r\nIn my case I wanted to add a rule for custom connections via `RuleProvider` without touching `BpmnRules` but since the information is thrown away my rule was beeing ignored.\r\n\r\n### Possible Fix\r\n\r\nA simple change to\r\n\r\n```\r\nmodeling.connect(source, target, typeof canExecute === 'object' && canExecute);\r\n```\r\n\r\nfixed this. Now in\r\n\r\n```\r\nModeling.prototype.connect = function(source, target, attrs) {\r\n\r\n  // ...\r\n\r\n  if (!attrs) {\r\n    attrs = bpmnRules.canConnect(source, target) || { type: 'bpmn:Association' };\r\n  }\r\n\r\n  // ...\r\n};\r\n```\r\n\r\n`attrs` is not undefined if my rule returned an object like `{ type: 'custom:connection }` and thereby is not ignored anymore."},"comment":{"url":"https://api.github.com/repos/bpmn-io/bpmn-js/issues/comments/217782613","html_url":"https://github.com/bpmn-io/bpmn-js/issues/536#issuecomment-217782613","issue_url":"https://api.github.com/repos/bpmn-io/bpmn-js/issues/536","id":217782613,"user":{"login":"nikku","id":58601,"avatar_url":"https://avatars.githubusercontent.com/u/58601?v=3","gravatar_id":"","url":"https://api.github.com/users/nikku","html_url":"https://github.com/nikku","followers_url":"https://api.github.com/users/nikku/followers","following_url":"https://api.github.com/users/nikku/following{/other_user}","gists_url":"https://api.github.com/users/nikku/gists{/gist_id}","starred_url":"https://api.github.com/users/nikku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikku/subscriptions","organizations_url":"https://api.github.com/users/nikku/orgs","repos_url":"https://api.github.com/users/nikku/repos","events_url":"https://api.github.com/users/nikku/events{/privacy}","received_events_url":"https://api.github.com/users/nikku/received_events","type":"User","site_admin":false},"created_at":"2016-05-09T06:05:34Z","updated_at":"2016-05-09T06:05:34Z","body":"Can you add a PR + test cases for this?"}}