Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <script>
class FlagIcon extends HTMLElement {
    constructor() {
        super();
    }
    static get observedAttributes() { return ["selectedCountry"]; }
    attributeChangedCallback(name, oldValue, newValue) {
        console.log(name, oldValue, newValue);
    }
}
customElements.define('flag-icon', FlagIcon);
    const el = document.createElement('flag-icon');
    
    // Converted, attributeChangedCallback not called
    console.log('first try:');
    el.setAttribute('selectedCountry', 'JP');
    // Not converted, attributeChangedCallback called
    console.log('second try:');
    el.setAttributeNS(null, 'selectedCountry', 'JP');
</script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers