Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TP2 - POO et Modules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathis Verleene
TP2 - POO et Modules
Commits
43eeec15
Commit
43eeec15
authored
4 years ago
by
Mathis Verleene
Browse files
Options
Downloads
Patches
Plain Diff
B.
parent
2382e328
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.js
+53
-40
53 additions, 40 deletions
src/main.js
with
53 additions
and
40 deletions
src/main.js
+
53
−
40
View file @
43eeec15
...
...
@@ -8,39 +8,52 @@ class Component {
this
.
children
=
children
;
}
render
()
{
if
(
typeof
children
!==
'
undefined
'
)
{
if
(
typeof
this
.
attribute
!==
'
undefined
'
&&
typeof
this
.
children
!==
'
undefined
'
)
{
return
`<
${
this
.
tagName
}
${
this
.
attribute
.
name
}
="
${
this
.
attribute
.
value
}
" >
${
this
.
children
}
</
${
this
.
tagName
}
`
;
}
if
(
typeof
this
.
children
!==
'
undefined
'
)
{
return
`<
${
this
.
tagName
}
>
${
this
.
children
}
</
${
this
.
tagName
}
>`
;
}
if
(
typeof
this
.
attribute
!==
'
undefined
'
)
{
return
`<
${
this
.
tagName
}
${
this
.
attribute
.
name
}
="
${
this
.
attribute
.
value
}
" />`
;
}
return
`<
${
this
.
tagName
}
/>`
;
}
}
const
img
=
new
Component
(
'
img
'
);
class
Img
extends
Component
{
constructor
(
url
)
{
super
(
'
img
'
,
{
name
:
'
src
'
,
value
:
url
});
}
}
const
img
=
new
Img
(
'
https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300
'
);
document
.
querySelector
(
'
.pageContent
'
).
innerHTML
=
img
.
render
();
const
data
=
[
{
const
data
=
[{
name
:
'
Regina
'
,
base
:
'
tomate
'
,
price_small
:
6.5
,
price_large
:
9.95
,
image
:
'
https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300
'
,
image
:
'
https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300
'
,
},
{
name
:
'
Napolitaine
'
,
base
:
'
tomate
'
,
price_small
:
6.5
,
price_large
:
8.95
,
image
:
'
https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300
'
,
image
:
'
https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300
'
,
},
{
name
:
'
Spicy
'
,
base
:
'
crème
'
,
price_small
:
5.5
,
price_large
:
8
,
image
:
'
https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300
'
,
image
:
'
https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300
'
,
},
];
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment