Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Developing and styling shadow elements</title>
  <style>
    error-message::shadow h1{
       color:red;
    }
  </style>
   <template id="errorTemplate">
     <style>
      :host h1{
          font-style:italic;
      }
     </style>
        
     <h1>
        Error Occured
     </h1>
   </template>
   <script>
        var objectPrototype = Object.create(HTMLElement.prototype);
        objectPrototype.createdCallback=function(){
            var shadow = this.createShadowRoot(),
                templateContent = document.querySelector('#errorTemplate').content,
                templateNodes = document.importNode(templateContent, true);
            shadow.appendChild(templateNodes);
        };
        var  myNameElement = document.registerElement("error-message",{
            prototype:objectPrototype
        });
    </script>
</head>
<body>
   <error-message>
    </error-message>
</body>
</html>
Output

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

Dismiss x
public
Bin info
saan1984pro
0viewers