SlideShare a Scribd company logo
mAppMechanic PolymerJS
PolymerJS
1
Session 3 - Custom Elements
PolymerJSmAppMechanic
Agenda
2
• What is Custom Polymer Element ?
• Registration of Custom Element
• Extending Native HTML Elements
• Declared Properties Basics
• Lifecycle Events
• Local DOM for Custom Elements
• Styling of Custom Elements
PolymerJSmAppMechanic
Custom Element
3
3
<my-app>
<app-content>
<iron-list>
<paper-button>
Inbuilt Button
</paper-button>
</iron-list>
</app-content>
</my-app>
PolymerJSmAppMechanic
(contd) Custom Element
4
4
★ Instantiated using a constructor or document.createElement.
★ Configured using attributes or properties.
★ Populated with internal DOM inside each instance.
★ Responsive to property and attribute changes (for example, by
populating data into the DOM, or firing an event).
★ Styled with internal defaults or externally.
★ Responsive to methods that manipulate its internal state.
Polymer provides a set of features to create your own Custom Elements
similar to creating like a Web Component using customElements v1 API. It
provides some added benefits over native web components. Important points
regarding it are:
PolymerJSmAppMechanic
Registration of Custom Element
5
5
Register a custom element using Polymer method & pass prototype of new
element. Prototype must have is property which will define name of Custom
HTML tag. The name should have a ‘-‘ in it.
PolymerJSmAppMechanic 6
PolymerJSmAppMechanic
Declare Properties
7
Add to the properties object, any data properties. You can accept any property
value through attributes too. All properties declared will be part of public API for
the element.
• In addition, the properties object can be used to specify:
• Property type.
• Default value.
• Read-only status. Prevents accidental changes to the property value.
• Computed property. Dynamically calculates a value based on other properties.
• Property reflection to attribute. Updates the corresponding attribute value when
the property value changes.
• Two-way data binding support. Fires an event whenever the property value
changes.
• Property change observer. Calls a method whenever the property value
changes.
PolymerJSmAppMechanic
Declare Properties
8
Example:
PolymerJSmAppMechanic
Declare Properties
9
The properties object supports the following keys for each property:
Key Details
type Type: constructor (one of Boolean, Date, Number, String, Array or Object)
value
Default value for the property. If value is a function, the function is invoked and
the return value is used as the default value of the property.
reflectToAttribute
Set to true to cause the corresponding attribute to be set on the host node when
the property value changes.
readOnly If true, the property can't be set directly by assignment or data binding.
notify
If true, the property is available for two-way data binding. In addition, an event,
property-name-changed is fired whenever the property changes.
computed The value is interpreted as a method name and argument list.
observer
The value is interpreted as a method name to be invoked when the property
value changes.
PolymerJSmAppMechanic 10
PolymerJSmAppMechanic
Lifecycle Events/Callbacks
11
Every custom element has lifecycle events associated. Polymer adds an extra
callback, ready, which is invoked when Polymer has finished creating and
initializing the element's local DOM.
Key Details
created
Called when element is created but before property values are set & local DOM
is created.
ready Called after local DOM is initialised and property values are set.
attached
Called after the element is attached to the document. Can be called multiple
times during the lifetime of an element.
detached
Called after the element is detached from the document. Can be called multiple
times during the lifetime of an element.
attributeChanged Called when one of the element's attributes is changed.
PolymerJSmAppMechanic
Lifecycle Events/Callbacks
12
Example:
PolymerJSmAppMechanic 13
PolymerJSmAppMechanic
Local DOM
14
The local DOM created and managed by any Custom Element is called
Local DOM. It is different from the Light DOM (children of web
components).
• Polymer uses native Shadow DOM for this wherever the Browsers
support it.
• Polymer uses a custom implementation called Shady DOM wherever the
Browser do not support shadow DOM. Shady DOM has a different API.
Polymer interface covers most of the common DOM methods and
properties, and is compatible with both shady DOM and native shadow
DOM.
PolymerJSmAppMechanic
Local DOM (Implementation)
15
The <script> tag can be
inside or outside of the <dom-
module> element.
The element’s template must
be parsed before the call to
Polymer.
PolymerJSmAppMechanic
(contd)Important Features
16
➡ Automatic Node Finding

Any node specified in the element's template with an id is stored
on the this.$ hash by id.
➡ this.$$(selector)

$$ returns the first node in the local DOM that matches selector.
➡ DOM distribution

The <content> element provides an insertion point at which an
element's light DOM is combined with its local DOM.
➡ DOM API

Polymer.dom API methods like insertBefore, appendChild,
removeChild.

Properties - innerHTML, textContent, firstChild, lastChild
PolymerJSmAppMechanic 17
PolymerJSmAppMechanic
Styling Custom Elements
18
Polymer uses Shadow DOM styling rules with scoped styles. Scoped styles
should be provided via <style> tags placed inside the element's local DOM
<template>.
PolymerJSmAppMechanic
(contd)Important Features
19
Key Details
Custom CSS
properties
Polymer provides a SHIM for Custom CSS Properties for Cascading Variables
Custom CSS
mixins
Define a set of CSS properties as a single custom property and then allow all
properties in the set to be applied to a specific CSS rule in an element's local
DOM.
Custom Property
API
updateStyles method to update styling dynamically
Shared Styles
Called after the element is detached from the document. Can be called multiple
times during the lifetime of an element.
attributeChanged Called when one of the element's attributes is changed.
PolymerJSmAppMechanic 20
mAppMechanic PolymerJS 21
Thanks
mAppMechanic
twitter.com/mAppMechanic
linkedin.com/in/rahatkh
yehtechnologies@gmail.com
Ad

More Related Content

What's hot (20)

ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
Fioriela Bego
 
Introduction to Webcomponents
Introduction to WebcomponentsIntroduction to Webcomponents
Introduction to Webcomponents
Harish Karthick
 
Spicing up SharePoint web parts
Spicing up SharePoint web partsSpicing up SharePoint web parts
Spicing up SharePoint web parts
Randy Williams
 
Rails Concept
Rails ConceptRails Concept
Rails Concept
Javed Hussain
 
angularJS Practicle Explanation
angularJS Practicle ExplanationangularJS Practicle Explanation
angularJS Practicle Explanation
Abhishek Sahu
 
Jsp & Ajax
Jsp & AjaxJsp & Ajax
Jsp & Ajax
Ang Chen
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
Jayantha Sirisena
 
Polymer
Polymer Polymer
Polymer
jskvara
 
Introduction To Asp.Net Ajax
Introduction To Asp.Net AjaxIntroduction To Asp.Net Ajax
Introduction To Asp.Net Ajax
Jeff Blankenburg
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
Mindfire Solutions
 
Milwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJSMilwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJS
Stan Carrico
 
Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
David Price
 
Making share point rock with angular and react
Making share point rock with angular and reactMaking share point rock with angular and react
Making share point rock with angular and react
Joseph Jorden
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
Premkumar M
 
Introduction ASP
Introduction ASPIntroduction ASP
Introduction ASP
FaTin GhaZmi
 
ASP.NET User Controls - 20090828
ASP.NET User Controls - 20090828ASP.NET User Controls - 20090828
ASP.NET User Controls - 20090828
Viral Patel
 
Meteor meetup
Meteor meetupMeteor meetup
Meteor meetup
David Brear
 
ASP.NET Brief History
ASP.NET Brief HistoryASP.NET Brief History
ASP.NET Brief History
Sudhakar Sharma
 
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
MskDotNet Community
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
Senthil Kumar
 
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
Fioriela Bego
 
Introduction to Webcomponents
Introduction to WebcomponentsIntroduction to Webcomponents
Introduction to Webcomponents
Harish Karthick
 
Spicing up SharePoint web parts
Spicing up SharePoint web partsSpicing up SharePoint web parts
Spicing up SharePoint web parts
Randy Williams
 
angularJS Practicle Explanation
angularJS Practicle ExplanationangularJS Practicle Explanation
angularJS Practicle Explanation
Abhishek Sahu
 
Jsp & Ajax
Jsp & AjaxJsp & Ajax
Jsp & Ajax
Ang Chen
 
Polymer
Polymer Polymer
Polymer
jskvara
 
Introduction To Asp.Net Ajax
Introduction To Asp.Net AjaxIntroduction To Asp.Net Ajax
Introduction To Asp.Net Ajax
Jeff Blankenburg
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
Mindfire Solutions
 
Milwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJSMilwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJS
Stan Carrico
 
Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
David Price
 
Making share point rock with angular and react
Making share point rock with angular and reactMaking share point rock with angular and react
Making share point rock with angular and react
Joseph Jorden
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
Premkumar M
 
ASP.NET User Controls - 20090828
ASP.NET User Controls - 20090828ASP.NET User Controls - 20090828
ASP.NET User Controls - 20090828
Viral Patel
 
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
MskDotNet Community
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
Senthil Kumar
 

Viewers also liked (16)

Web Components: Rethinking Web App Development
Web Components: Rethinking Web App DevelopmentWeb Components: Rethinking Web App Development
Web Components: Rethinking Web App Development
Lukáš Fryč
 
Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...
Marios Fakiolas
 
513 introduction-to-unbalance
513 introduction-to-unbalance513 introduction-to-unbalance
513 introduction-to-unbalance
noam29shaked
 
New World of Angular (v2+)
New World of Angular (v2+)New World of Angular (v2+)
New World of Angular (v2+)
Rahat Khanna a.k.a mAppMechanic
 
Intro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin ElementsIntro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin Elements
Manuel Carrasco Moñino
 
PolymerJS 開發實戰
PolymerJS 開發實戰PolymerJS 開發實戰
PolymerJS 開發實戰
益祥 許
 
Balancing machines
Balancing machinesBalancing machines
Balancing machines
wintec
 
Balancing of Shafts
Balancing of ShaftsBalancing of Shafts
Balancing of Shafts
Leicester College- Technology & Engineering Centre
 
Subject presiontation of dynamics of motion
Subject presiontation of dynamics of motionSubject presiontation of dynamics of motion
Subject presiontation of dynamics of motion
kgondaliya07
 
Dynamics of Machinery Unit III
Dynamics of Machinery Unit IIIDynamics of Machinery Unit III
Dynamics of Machinery Unit III
Vaidyanathan Ramakrishnan
 
Ppt mech 5sem_dom
Ppt mech 5sem_domPpt mech 5sem_dom
Ppt mech 5sem_dom
vbrayka
 
Dynamics of Machinery Unit IV
Dynamics of Machinery Unit IVDynamics of Machinery Unit IV
Dynamics of Machinery Unit IV
Vaidyanathan Ramakrishnan
 
Balancing presentation
Balancing presentationBalancing presentation
Balancing presentation
pasha55
 
Vibration Monitoring
Vibration Monitoring Vibration Monitoring
Vibration Monitoring
IONEL DUTU
 
Mechanical Vibration- An introduction
Mechanical Vibration- An introductionMechanical Vibration- An introduction
Mechanical Vibration- An introduction
Hareesha N Gowda, Dayananda Sagar College of Engg, Bangalore
 
Polymer ppt
Polymer pptPolymer ppt
Polymer ppt
Malaviya National Institute Of Technology Jaipur
 
Ad

Similar to MAppMechanic CodeLabs - PolymerJS Custom Elements (20)

Polymer 2.0 codelab for extreme beginners
Polymer 2.0 codelab for extreme beginnersPolymer 2.0 codelab for extreme beginners
Polymer 2.0 codelab for extreme beginners
Sylia Baraka
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive Final
RJ Owen
 
KnockoutJS and MVVM
KnockoutJS and MVVMKnockoutJS and MVVM
KnockoutJS and MVVM
Manvendra Singh
 
Dyanaimcs of business and economics unit 2
Dyanaimcs of business and economics unit 2Dyanaimcs of business and economics unit 2
Dyanaimcs of business and economics unit 2
jpm071712
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
Simon Gauvin
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
DayNightGaMiNg
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
Mike Nakhimovich
 
iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021
Jason Flax
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Bhushan Mulmule
 
React and Flux life cycle with JSX, React Router and Jest Unit Testing
React and  Flux life cycle with JSX, React Router and Jest Unit TestingReact and  Flux life cycle with JSX, React Router and Jest Unit Testing
React and Flux life cycle with JSX, React Router and Jest Unit Testing
Eswara Kumar Palakollu
 
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
sharvaridhokte
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
janet736113
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
DayNightGaMiNg
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Web components
Web componentsWeb components
Web components
Mohd Saeed
 
Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language Performance
Kevin Hazzard
 
Java on Google App engine
Java on Google App engineJava on Google App engine
Java on Google App engine
Michael Parker
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
Codemotion
 
React more than just components
React   more than just componentsReact   more than just components
React more than just components
Chen Feldman
 
Polymer 2.0 codelab for extreme beginners
Polymer 2.0 codelab for extreme beginnersPolymer 2.0 codelab for extreme beginners
Polymer 2.0 codelab for extreme beginners
Sylia Baraka
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive Final
RJ Owen
 
Dyanaimcs of business and economics unit 2
Dyanaimcs of business and economics unit 2Dyanaimcs of business and economics unit 2
Dyanaimcs of business and economics unit 2
jpm071712
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
Simon Gauvin
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
Mike Nakhimovich
 
iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021
Jason Flax
 
React and Flux life cycle with JSX, React Router and Jest Unit Testing
React and  Flux life cycle with JSX, React Router and Jest Unit TestingReact and  Flux life cycle with JSX, React Router and Jest Unit Testing
React and Flux life cycle with JSX, React Router and Jest Unit Testing
Eswara Kumar Palakollu
 
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
sharvaridhokte
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
janet736113
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Web components
Web componentsWeb components
Web components
Mohd Saeed
 
Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language Performance
Kevin Hazzard
 
Java on Google App engine
Java on Google App engineJava on Google App engine
Java on Google App engine
Michael Parker
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
Codemotion
 
React more than just components
React   more than just componentsReact   more than just components
React more than just components
Chen Feldman
 
Ad

More from Rahat Khanna a.k.a mAppMechanic (11)

Introduction to React Native & Rendering Charts / Graphs
Introduction to React Native & Rendering Charts / GraphsIntroduction to React Native & Rendering Charts / Graphs
Introduction to React Native & Rendering Charts / Graphs
Rahat Khanna a.k.a mAppMechanic
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
15th june
15th june15th june
15th june
Rahat Khanna a.k.a mAppMechanic
 
13th june
13th june13th june
13th june
Rahat Khanna a.k.a mAppMechanic
 
10th june
10th june10th june
10th june
Rahat Khanna a.k.a mAppMechanic
 
9th june
9th june9th june
9th june
Rahat Khanna a.k.a mAppMechanic
 
7th june
7th june7th june
7th june
Rahat Khanna a.k.a mAppMechanic
 
4th june
4th june4th june
4th june
Rahat Khanna a.k.a mAppMechanic
 
9th june
9th june9th june
9th june
Rahat Khanna a.k.a mAppMechanic
 
3rd june
3rd june3rd june
3rd june
Rahat Khanna a.k.a mAppMechanic
 
2nd june
2nd june 2nd june
2nd june
Rahat Khanna a.k.a mAppMechanic
 

Recently uploaded (20)

Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 

MAppMechanic CodeLabs - PolymerJS Custom Elements

  • 2. PolymerJSmAppMechanic Agenda 2 • What is Custom Polymer Element ? • Registration of Custom Element • Extending Native HTML Elements • Declared Properties Basics • Lifecycle Events • Local DOM for Custom Elements • Styling of Custom Elements
  • 4. PolymerJSmAppMechanic (contd) Custom Element 4 4 ★ Instantiated using a constructor or document.createElement. ★ Configured using attributes or properties. ★ Populated with internal DOM inside each instance. ★ Responsive to property and attribute changes (for example, by populating data into the DOM, or firing an event). ★ Styled with internal defaults or externally. ★ Responsive to methods that manipulate its internal state. Polymer provides a set of features to create your own Custom Elements similar to creating like a Web Component using customElements v1 API. It provides some added benefits over native web components. Important points regarding it are:
  • 5. PolymerJSmAppMechanic Registration of Custom Element 5 5 Register a custom element using Polymer method & pass prototype of new element. Prototype must have is property which will define name of Custom HTML tag. The name should have a ‘-‘ in it.
  • 7. PolymerJSmAppMechanic Declare Properties 7 Add to the properties object, any data properties. You can accept any property value through attributes too. All properties declared will be part of public API for the element. • In addition, the properties object can be used to specify: • Property type. • Default value. • Read-only status. Prevents accidental changes to the property value. • Computed property. Dynamically calculates a value based on other properties. • Property reflection to attribute. Updates the corresponding attribute value when the property value changes. • Two-way data binding support. Fires an event whenever the property value changes. • Property change observer. Calls a method whenever the property value changes.
  • 9. PolymerJSmAppMechanic Declare Properties 9 The properties object supports the following keys for each property: Key Details type Type: constructor (one of Boolean, Date, Number, String, Array or Object) value Default value for the property. If value is a function, the function is invoked and the return value is used as the default value of the property. reflectToAttribute Set to true to cause the corresponding attribute to be set on the host node when the property value changes. readOnly If true, the property can't be set directly by assignment or data binding. notify If true, the property is available for two-way data binding. In addition, an event, property-name-changed is fired whenever the property changes. computed The value is interpreted as a method name and argument list. observer The value is interpreted as a method name to be invoked when the property value changes.
  • 11. PolymerJSmAppMechanic Lifecycle Events/Callbacks 11 Every custom element has lifecycle events associated. Polymer adds an extra callback, ready, which is invoked when Polymer has finished creating and initializing the element's local DOM. Key Details created Called when element is created but before property values are set & local DOM is created. ready Called after local DOM is initialised and property values are set. attached Called after the element is attached to the document. Can be called multiple times during the lifetime of an element. detached Called after the element is detached from the document. Can be called multiple times during the lifetime of an element. attributeChanged Called when one of the element's attributes is changed.
  • 14. PolymerJSmAppMechanic Local DOM 14 The local DOM created and managed by any Custom Element is called Local DOM. It is different from the Light DOM (children of web components). • Polymer uses native Shadow DOM for this wherever the Browsers support it. • Polymer uses a custom implementation called Shady DOM wherever the Browser do not support shadow DOM. Shady DOM has a different API. Polymer interface covers most of the common DOM methods and properties, and is compatible with both shady DOM and native shadow DOM.
  • 15. PolymerJSmAppMechanic Local DOM (Implementation) 15 The <script> tag can be inside or outside of the <dom- module> element. The element’s template must be parsed before the call to Polymer.
  • 16. PolymerJSmAppMechanic (contd)Important Features 16 ➡ Automatic Node Finding
 Any node specified in the element's template with an id is stored on the this.$ hash by id. ➡ this.$$(selector)
 $$ returns the first node in the local DOM that matches selector. ➡ DOM distribution
 The <content> element provides an insertion point at which an element's light DOM is combined with its local DOM. ➡ DOM API
 Polymer.dom API methods like insertBefore, appendChild, removeChild.
 Properties - innerHTML, textContent, firstChild, lastChild
  • 18. PolymerJSmAppMechanic Styling Custom Elements 18 Polymer uses Shadow DOM styling rules with scoped styles. Scoped styles should be provided via <style> tags placed inside the element's local DOM <template>.
  • 19. PolymerJSmAppMechanic (contd)Important Features 19 Key Details Custom CSS properties Polymer provides a SHIM for Custom CSS Properties for Cascading Variables Custom CSS mixins Define a set of CSS properties as a single custom property and then allow all properties in the set to be applied to a specific CSS rule in an element's local DOM. Custom Property API updateStyles method to update styling dynamically Shared Styles Called after the element is detached from the document. Can be called multiple times during the lifetime of an element. attributeChanged Called when one of the element's attributes is changed.
  翻译: