-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS errors from malformed project html no longer disable the Start Over button. #29395
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,12 @@ export default { | |
} | ||
// Unknown elements are expected. Return null because we don't know type. | ||
if (allowUnknown) { | ||
console.warn( | ||
'Project contains an element with an unknown type' + | ||
`\nType: ${element.tagName}` + | ||
`\nId: ${element.id}` + | ||
`\nClass: ${element.className}` | ||
); | ||
return null; | ||
} | ||
throw new Error('unknown element type'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we ever want to throw on unknown elements? If not, maybe we don't need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll look a bit deeper. It would be nice to remove this throw. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Took a deeper look - there are a lot of areas that rely on this returning something. Additionally, there are a lot of areas that throw when there is a bad design element. I've created a task to look into a better way to approach our strategy on handling malformed design elements. |
||
|
@@ -203,9 +209,13 @@ export default { | |
* Code to be called after deserializing element, allowing us to attach any | ||
* necessary event handlers. | ||
*/ | ||
onDeserialize: function(element, updateProperty) { | ||
var elementType = this.getElementType(element); | ||
if (elements[elementType] && elements[elementType].onDeserialize) { | ||
onDeserialize: function(element, updateProperty, skipIfUnknown) { | ||
var elementType = this.getElementType(element, skipIfUnknown); | ||
if ( | ||
elementType && | ||
elements[elementType] && | ||
elements[elementType].onDeserialize | ||
) { | ||
elements[elementType].onDeserialize(element, updateProperty); | ||
} | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1114,7 +1114,8 @@ function getUnsafeHtmlReporter(sanitizationTarget) { | |
designMode.parseScreenFromLevelHtml = function( | ||
screenEl, | ||
allowDragging, | ||
prefix | ||
prefix, | ||
skipUnknownElements | ||
) { | ||
var screen = $(screenEl); | ||
elementUtils.addIdPrefix(screen[0], prefix); | ||
|
@@ -1132,7 +1133,8 @@ designMode.parseScreenFromLevelHtml = function( | |
var element = $(this).hasClass('ui-draggable') ? this.firstChild : this; | ||
elementLibrary.onDeserialize( | ||
element, | ||
designMode.updateProperty.bind(element) | ||
designMode.updateProperty.bind(element), | ||
skipUnknownElements | ||
); | ||
}); | ||
return screen[0]; | ||
|
@@ -1164,7 +1166,7 @@ designMode.parseFromLevelHtml = function(rootEl, allowDragging, prefix) { | |
); | ||
var children = $(levelDom).children(); | ||
children.each(function() { | ||
designMode.parseScreenFromLevelHtml(this, allowDragging, prefix); | ||
designMode.parseScreenFromLevelHtml(this, allowDragging, prefix, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: add a comment for the boolean parameter: |
||
}); | ||
children.appendTo(rootEl); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we log this to firebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synced offline: Don't need to log to firehose. The intent of having this warning is to help with diagnosing issues that come in via Zendesk. Issues like this will persist, so we won't need to track a single event in time. Additionally, it's not particularly valuable to track how many times this happens.