kelp404 / angular-form-builder

Drag and drop to build bootstrap forms in AngularJS.
http://kelp404.github.io/angular-form-builder/
MIT License
599 stars 340 forks source link

TypeError: Cannot read property 'ownerDocument' of undefined #114

Open bitflower opened 7 years ago

bitflower commented 7 years ago

Hi,

I'm running the form builder since 2014 in a project of a customer.

We now have updated Angular to 1.6.5 (from 1.5.9), Bootstrap to 3.3.7 (from 3.3.6) and jQuery from 2.2.4 to 3.1.1 (from 2.2.4).

After these updates we get the error mentioned.

I have done some investigations and found out that there is a connection to jQuery and Sizzle.js. In the .contains() method the ownerDocument is not set. In a long chain of calls the initial call that is causing the problem is the last line in the below block - return $(element).html(view);:

.directive('fbComponent', [ '$injector', function($injector) { var $builder, $compile, $drag; $builder = $injector.get('$builder'); $drag = $injector.get('$drag'); $compile = $injector.get('$compile'); return { restrict: 'A', scope: { component: '=fbComponent' }, controller: 'fbComponentController', link: function(scope, element) { scope.copyObjectToScope(scope.component); $drag.draggable($(element), { mode: 'mirror', defer: false, object: { componentName: scope.component.name } }); return scope.$watch('component.template', function(template) { var view; if (!template) { return; } view = $compile(template)(scope); return $(element).html(view); }); } };

What I find strange is that view object is handed over to html() instead of just the html-content (The view object contains way more properties and is not just a string of html).

I have the feeling that this is somehow related to the jQuery / jQLite update to version 3 which came with Angular 1.6.

Any ideas?

johnlim commented 6 years ago

Hi @bitflower, did you ever resolve this?

blinder commented 1 year ago

I've just happened across this in some old code after upgrading to the latest angularjs. Anyone know of a fix. And @bitflower your observation about passing back the whole view object does strike me as a bit odd as well. Just pass back the compiled view as a string of HTML?