# Étendre des composants et des plugins avec EXTENSION

> Ajoutez un comportement à un composant existant depuis l'extérieur, sans modifier son code source, avec EXTENSION().

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: fr
Content-SHA256: 769a5ce510e59bf8cacec936fefc3e54e2c135679e7f9e6330c1f93a571bb5b0
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: jcomponent20@3fedd009a277f50fddc608b97afbec553b67c51b
Review: not-recorded

`EXTENSION(name, config, callback)` ajoute du code à chaque instance du composant `name` (ou du plugin `@name`) lors de sa création. Le callback reçoit l'instance et sa config, exactement comme une déclaration : vous pouvez donc ajouter des méthodes, modifier des options ou écouter des événements. C'est ainsi qu'une application personnalise des composants tiers sans les forker.

```html public/index.html
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>jComponent</title>
	<link rel="stylesheet" href="//cdn.componentator.com/spa.min@20.css" />
	<script src="//cdn.componentator.com/spa.min@20.js"></script>
</head>
<body>
	<ui-component name="label" config="text:Hello"></ui-component>

	<script>

		COMPONENT('label', 'text:', function(self, config) {
			self.make = function() {
				self.html('<span></span>');
				self.find('span').text(config.text);
			};
		});

		EXTENSION('label', 'suffix:!', function(self, config) {
			self.shout = function() {
				self.find('span').text(config.text.toUpperCase() + config.suffix);
			};
			self.extended = true;
		});

	</script>

</body>
</html>
```
