-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix missing componentName in DoughBaseComponent #219
Conversation
Found this to get function name which would avoid the need to specify the componentName: https://gist.github.com/ourmaninamsterdam/53e5b87167a411ada149 |
var warning; | ||
|
||
if (typeof componentName !== 'undefined') { | ||
if (this.$el.data('dough-component').indexOf(componentName)) { |
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.
Does this need indexOf(componentName) >= -1
?
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.
Sorry > -1
9baa951
to
43743da
Compare
* @returns {string} eg. tab-selector | ||
*/ | ||
convertCamelCaseToDashed: function(str) { | ||
var val = str.replace(/[A-Z]/g, function(match) { |
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.
I realise you've just moved this function but it currently doesn't handle cases like `MASComponent' correctly
LGTM 👍 |
@@ -2,6 +2,13 @@ describe('componentLoader', function() { | |||
|
|||
'use strict'; | |||
|
|||
function convertCamelCaseToDashed(str) { |
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.
Does copying this code to the spec actually test anything? If the production code has an issue, so does the test and it isn't caught.
c593038
to
ad1b62a
Compare
b9434dc
to
c8d7e85
Compare
This looks great 👍 |
c8d7e85
to
ced2f01
Compare
@benbarnett We discussed the dependency resolution issues that could occur when including the |
Hmm, yeah sadly this will only work when the engines are mounted, as they inherit the require config from frontend. We'd need to add them individually to the engines to get their tests to pass. I suppose an alternative could just be to merge utilities into DoughBaseComponent? |
Just discussed this in person, including the |
Will now match MASComponent.
`componentName` is set on the prototype.
ced2f01
to
52f515c
Compare
Travis failing is an issue separate to this and shouldn't hold up the merge. I've run the tests locally and all looks good 👍 |
@@ -34,6 +34,8 @@ define(['jquery', 'DoughBaseComponent'], function($, DoughBaseComponent) { | |||
|
|||
DoughBaseComponent.extend(FieldHelpText); | |||
|
|||
FieldHelpText.componentName = 'FieldHelpText'; |
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.
Weird indentation here
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.
Fixed
…-name Fix missing componentName in DoughBaseComponent
This PR accomplishes the following:
new FooComponent()
) without usingcomponentLoader
. Before initialising a component directly would return stampdata-dough-undefined-initialised="yes"
. It now properly setsdata-dough-foo-initialised="yes"
. It does this by moving responsibility of setting thecomponentName
toDoughBaseComponent
. Seecomponentname
is not being set in DoughBaseComponent #218 for the original bug.componentName
's to default Dough components