Skip to content

Commit

Permalink
feat: basic custom element
Browse files Browse the repository at this point in the history
  • Loading branch information
ap221882 committed Jan 27, 2023
1 parent 796c61b commit 4ac0f10
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Revision/custom-components/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Web Components</title>
<script src="script.js"></script>
<style>
:not(:defined) {
background-color: red;
}
</style>
</head>
<body>
<ajay-pathak>Ajay</ajay-pathak>
</body>
</html>
25 changes: 25 additions & 0 deletions Revision/custom-components/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// const elementNotDefined = document.createElement('ajay-pathak');
// document.body.appendChild(elementNotDefined);

class MyCustomElement extends HTMLElement {
constructor() {
super();
//% Element created
console.log('I am created - constructor');
}

connectedCallback() {
//% Element connected
console.log('I am mounted - connected');
}

disconnectedCallback() {
console.log('I am removed- disconnected');
}
}

customElements.define('ajay-pathak', MyCustomElement);

const element = document.getElementsByTagName('ajay-pathak');
console.log(element);
// element[0].remove();

2 comments on commit 4ac0f10

@vercel
Copy link

@vercel vercel bot commented on 4ac0f10 Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

namaste-react-parcel – ./Day3

namaste-react-parcel.vercel.app
namaste-react-parcel-git-main-ap221882.vercel.app
namaste-react-parcel-ap221882.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4ac0f10 Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

namaste-react – ./Day12/github-api-project-ts

namaste-react-git-main-ap221882.vercel.app
namaste-react.vercel.app
namaste-react-ap221882.vercel.app

Please sign in to comment.