Use 'string' library to generate panel header's id#89
Use 'string' library to generate panel header's id#89yamgent merged 1 commit intoMarkBind:masterfrom
Conversation
|
As discussed, fix doesn't work with MarkBind/markbind#392 (comment). |
src/Panel.vue
Outdated
| const panelHeaderText = jQuery(this.headerContent).wrap('<div></div>').parent().find(':header').text(); | ||
| this.$refs.cardContainer.setAttribute('id', string(panelHeaderText).slugify().toString()); | ||
| } else if(this.$refs.headerWrapper.innerHTML) { | ||
| this.$refs.cardContainer.setAttribute('id', jQuery(this.$refs.headerWrapper.innerHTML).wrap('<div></div>').parent().find(':header')[0].id); |
There was a problem hiding this comment.
Will this cause an error if there is no header at all?
Maybe try something like this instead?
const header = this.$refs.headerWrapper.innerHTML).wrap('<div></div>').parent().find(':header');
if (header.length > 0) {
this.$refs.cardContainer.setAttribute('id', header[0].id);
}
src/Panel.vue
Outdated
|
|
||
| if (this.headerContent) { | ||
| const panelHeaderText = jQuery(this.headerContent).wrap('<div></div>').parent().find(':header').text(); | ||
| this.$refs.cardContainer.setAttribute('id', string(panelHeaderText).slugify().toString()); |
There was a problem hiding this comment.
you will still need to check if (panelHeaderText) {, otherwise it is possible for the id to be blank.
yamgent
left a comment
There was a problem hiding this comment.
As above. If you have made the changes, do remember to push them to your branch.
src/Panel.vue
Outdated
| this.$refs.cardContainer.setAttribute('id', string(panelHeaderText).slugify().toString()); | ||
| } | ||
| } else if(this.$refs.headerWrapper.innerHTML) { | ||
| const header = this.$refs.headerWrapper.innerHTML).wrap('<div></div>').parent().find(':header'); |
There was a problem hiding this comment.
This line doesn't compile (it should be jQuery(this.$refs.headerWrapper.innerHTML)?)
src/Panel.vue
Outdated
|
|
||
| if (this.headerContent) { | ||
| const panelHeaderText = jQuery(this.headerContent).wrap('<div></div>').parent().find(':header').text(); | ||
| if(panelHeaderText) { |
There was a problem hiding this comment.
Should have a space after if: if (panelHeaderText) {
src/Panel.vue
Outdated
| if(panelHeaderText) { | ||
| this.$refs.cardContainer.setAttribute('id', string(panelHeaderText).slugify().toString()); | ||
| } | ||
| } else if(this.$refs.headerWrapper.innerHTML) { |
There was a problem hiding this comment.
Same issue: should have space after if.
140593b to
8b5d16f
Compare
|
Not sure what happened, but I can't get it to work now? It now shows this error on the console: Also the commit message can be a bit better (can just be the same as the PR title). |
dc5458f to
25b946e
Compare
yamgent
left a comment
There was a problem hiding this comment.
I still cannot jump to tutorial-timetable-tutor-roletimesvenue. I checked the source and apparently the ID is not generated?
src/Panel.vue
Outdated
| if (panelHeaderText) { | ||
| this.$refs.cardContainer.setAttribute('id', string(panelHeaderText).slugify().toString()); | ||
| } | ||
| } else if (this.$refs.innerHTML) { |
There was a problem hiding this comment.
Is this supposed to be this.$refs.headerWrapper.innerHTML?
25b946e to
cad5f67
Compare
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [ ] Documentation update
• [X] Bug fix
• [ ] New feature
• [ ] Enhancement to an existing feature
• [ ] Other, please explain:
Fixes MarkBind/markbind#392.
What is the rationale for this request?
The MarkBind repo is using
markdown-it-anchorto generate theids for Markdown heading, and it uses thestringlibrary. For consistency, we should use the same library for vue-strap.What changes did you make? (Give an overview)
Import the
stringlibrary, use it to generate the ids instead of using our own regex.Testing instructions:
npm installnpm run buildin vue-strap repoeg: search "unsafe"