Moves default form outside of sfSchema's $watch so compiling works #472
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There's a really weird long error on compilation if you have an empty or falsey default form:
Source of issue
$digest
repeatedly calls watch; on each call, when scope.initialForm is falsey,var form
gets a new copy of[*]
; on successive calls, new copy doesn't equal old and the scope gets modified so$digest
makes another loop.This works as expected -
Full original error message...
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [[{"msg":"schemaForm.form[0]","newVal":{"title":"First Name","description":"First Name","schema":{"id":"https://api.yeti-support.com#/definitions/first_name","type":"string","minLength":1,"title":"First Name","description":"First Name","name":"first_name"},"ngModelOptions":{},"key":["first_name"],"type":"text"}},{"msg":"schemaForm.form[1]","newVal":{"title":"Last Name","description":"Last Name","schema":{"id":"https://api.yeti-support.com#/definitions/last_name","type":"string","minLength":1,"title":"Last Name","description":"Last Name","name":"last_name"},"ngModelOptions":{},"key":["last_name"],"type":"text"}},{"msg":"schemaForm.form[2]","newVal":{"title":"Slug","description":"Slug","schema":{"id":"https://api.yeti-support.com#/definitions/slug","type":"string","minLength":6,"title":"Slug","description":"Slug","name":"slug"},"ngModelOptions":{},"key":["slug"],"type":"text"}},{"msg":"schemaForm.form[3]","newVal":{"title":"Password","description":"Password","schema":{"id":"https://api.yeti-support.com#/definitions/password","type":"string","minLength":1,"title":"Password","description":"Password","name":"password","default":"Password"},"ngModelOptions":{},"key":["password"],"type":"text"}},{"msg":"schemaForm.form[4]","newVal":{"title":"Spam","description":"Indicates whether the item is marked as spam","schema":{"id":"https://api.yeti-support.com#/definitions/spam","type":"boolean","title":"Spam","description":"Indicates whether the item is marked as spam","name":"spam","default":false},"ngModelOptions":{},"key":["spam"],"type":"checkbox"}},{"msg":"schemaForm.form[5]","newVal":{"title":"Google 2FA Token","description":"Google 2FA Token","schema":{"id":"https://api.yeti-support.com#/definitions/two_factor_token","type":"string","minLength":1,"title":"Google 2FA Token","description":"Google 2FA Token","name":"two_factor_token"},"ngModelOptions":{},"key":["two_factor_token"],"type":"text"}},{"msg":"schemaForm.form[6]","newVal":{"title":"E-mail Address","description":"E-mail Address","schema":{"id":"https://api.yeti-support.com#/definitions/email","type":"string","minLength":1,"title":"E-mail Address","description":"E-mail Address","name":"email","default":"email@address.com"},"ngModelOptions":{},"key":["email"],"type":"text"}}],[{"msg":"schemaForm.form[0]","newVal":{"title":"First Name","description":"First Name","schema":"<<already seen>>","ngModelOptions":{},"key":["first_name"],"type":"text"}},{"msg":"schemaForm.form[1]","newVal":{"title":"Last Name","description":"Last Name","schema":"<<already seen>>","ngModelOptions":{},"key":["last_name"],"type":"text"}},{"msg":"schemaForm.form[2]","newVal":{"title":"Slug","description":"Slug","schema":"<<already seen>>","ngModelOptions":{},"key":["slug"],"type":"text"}},{"msg":"schemaForm.form[3]","newVal":{"title":"Password","description":"Password","schema":"<<already seen>>","ngModelOptions":{},"key":["password"],"type":"text"}},{"msg":"schemaForm.form[4]","newVal":{"title":"Spam","description":"Indicates whether the item is marked as spam","schema":"<<already seen>>","ngModelOptions":{},"key":["spam"],"type":"checkbox"}},{"msg":"schemaForm.form[5]","newVal":{"title":"Google 2FA Token","description":"Google 2FA Token","schema":"<<already seen>>","ngModelOptions":{},"key":["two_factor_token"],"type":"text"}},{"msg":"schemaForm.form[6]","newVal":{"title":"E-mail Address","description":"E-mail Address","schema":"<<already seen>>","ngModelOptions":{},"key":["email"],"type":"text"}}],[{"msg":"schemaForm.form[0]","newVal":{"title":"First Name","description":"First Name","schema":"<<already seen>>","ngModelOptions":{},"key":["first_name"],"type":"text"}},{"msg":"schemaForm.form[1]","newVal":{"title":"Last Name","description":"Last Name","schema":"<<already seen>>","ngModelOptions":{},"key":["last_name"],"type":"text"}},{"msg":"schemaForm.form[2]","newVal":{"title":"Slug","description":"Slug","schema":"<<already seen>>","ngModelOptions":{},"key":["slug"],"type":"text"}},{"msg":"schemaForm.form[3]","newVal":{"title":"Password","description":"Password","schema":"<<already seen>>","ngModelOptions":{},"key":["password"],"type":"text"}},{"msg":"schemaForm.form[4]","newVal":{"title":"Spam","description":"Indicates whether the item is marked as spam","schema":"<<already seen>>","ngModelOptions":{},"key":["spam"],"type":"checkbox"}},{"msg":"schemaForm.form[5]","newVal":{"title":"Google 2FA Token","description":"Google 2FA Token","schema":"<<already seen>>","ngModelOptions":{},"key":["two_factor_token"],"type":"text"}},{"msg":"schemaForm.form[6]","newVal":{"title":"E-mail Address","description":"E-mail Address","schema":"<<already seen>>","ngModelOptions":{},"key":["email"],"type":"text"}}],[{"msg":"schemaForm.form[0]","newVal":{"title":"First Name","description":"First Name","schema":"<<already seen>>","ngModelOptions":{},"key":["first_name"],"type":"text"}},{"msg":"schemaForm.form[1]","newVal":{"title":"Last Name","description":"Last Name","schema":"<<already seen>>","ngModelOptions":{},"key":["last_name"],"type":"text"}},{"msg":"schemaForm.form[2]","newVal":{"title":"Slug","description":"Slug","schema":"<<already seen>>","ngModelOptions":{},"key":["slug"],"type":"text"}},{"msg":"schemaForm.form[3]","newVal":{"title":"Password","description":"Password","schema":"<<already seen>>","ngModelOptions":{},"key":["password"],"type":"text"}},{"msg":"schemaForm.form[4]","newVal":{"title":"Spam","description":"Indicates whether the item is marked as spam","schema":"<<already seen>>","ngModelOptions":{},"key":["spam"],"type":"checkbox"}},{"msg":"schemaForm.form[5]","newVal":{"title":"Google 2FA Token","description":"Google 2FA Token","schema":"<<already seen>>","ngModelOptions":{},"key":["two_factor_token"],"type":"text"}},{"msg":"schemaForm.form[6]","newVal":{"title":"E-mail Address","description":"E-mail Address","schema":"<<already seen>>","ngModelOptions":{},"key":["email"],"type":"text"}}],[{"msg":"schemaForm.form[0]","newVal":{"title":"First Name","description":"First Name","schema":"<<already seen>>","ngModelOptions":{},"key":["first_name"],"type":"text"}},{"msg":"schemaForm.form[1]","newVal":{"title":"Last Name","description":"Last Name","schema":"<<already seen>>","ngModelOptions":{},"key":["last_name"],"type":"text"}},{"msg":"schemaForm.form[2]","newVal":{"title":"Slug","description":"Slug","schema":"<<already seen>>","ngModelOptions":{},"key":["slug"],"type":"text"}},{"msg":"schemaForm.form[3]","newVal":{"title":"Password","description":"Password","schema":"<<already seen>>","ngModelOptions":{},"key":["password"],"type":"text"}},{"msg":"schemaForm.form[4]","newVal":{"title":"Spam","description":"Indicates whether the item is marked as spam","schema":"<<already seen>>","ngModelOptions":{},"key":["spam"],"type":"checkbox"}},{"msg":"schemaForm.form[5]","newVal":{"title":"Google 2FA Token","description":"Google 2FA Token","schema":"<<already seen>>","ngModelOptions":{},"key":["two_factor_token"],"type":"text"}},{"msg":"schemaForm.form[6]","newVal":{"title":"E-mail Address","description":"E-mail Address","schema":"<<already seen>>","ngModelOptions":{},"key":["email"],"type":"text"}}]]
footnote - Tests weren't working locally; I did verify the fix in-place.