Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e8d525d0
Commit
e8d525d0
authored
Mar 10, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds best practices regarding context and vue to documentation
parent
c4ba6ea6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
doc/development/frontend.md
doc/development/frontend.md
+32
-1
No files found.
doc/development/frontend.md
View file @
e8d525d0
...
...
@@ -66,6 +66,8 @@ Let's look into each of them:
This is the index file of your new feature. This is where the root Vue instance
of the new feature should be.
The Store and the Service should be loaded in this file and provided as a prop to the main component.
Don't forget to follow
[
these steps.
][
page_specific_javascript
]
**A folder for Components**
...
...
@@ -86,7 +88,7 @@ You can read more about components in Vue.js site, [Component System][component-
**A folder for the Store**
The Store is a
simple object
that allows us to manage the state in a single
The Store is a
class
that allows us to manage the state in a single
source of truth.
The concept we are trying to follow is better explained by Vue documentation
...
...
@@ -332,6 +334,34 @@ gl.MyThing = MyThing;
```
### Manipulating the DOM in a JS Class
When writing a class that needs to manipulate the DOM guarantee a container option is provided.
This is useful when we need that class to be instantiated more than once in the same page.
Bad:
```
class Foo {
constructor() {
document.querySelector('.bar');
}
}
new Foo();
```
Good:
```
class Foo {
constructor(opts) {
document.querySelector(opts.container);
}
}
new Foo({ container: '.my-element' });
```
You can find an example of the above in this
[
class
][
container-class-example
]
;
## Supported browsers
For our currently-supported browsers, see our
[
requirements
][
requirements
]
.
...
...
@@ -457,3 +487,4 @@ Scenario: Developer can approve merge request
[
eslintrc
]:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/.eslintrc
[
team-page
]:
https://about.gitlab.com/team
[
vue-section
]:
https://docs.gitlab.com/ce/development/frontend.html#how-to-build-a-new-feature-with-vue-js
[
container-class-example
]:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/mini_pipeline_graph_dropdown.js
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment