/**
 * @license
 * Copyright 2016 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.u2',
  name: 'HTMLValidator',
  extends: 'foam.u2.DefaultValidator',

  axioms: [ foam.pattern.Singleton.create() ],

  methods: [
    function sanitizeText(text) {
      // TODO: validate text
      return text;
    }
  ]
});


// An Element which does not escape HTML content
foam.CLASS({
  package: 'foam.u2',
  name: 'HTMLElement',
  extends: 'foam.u2.Element',

  exports: [ 'validator as elementValidator' ],

  properties: [
    {
      class: 'Proxy',
      of: 'foam.u2.DefaultValidator',
      name: 'validator',
      value: foam.u2.HTMLValidator.create()
    }
  ]
});

@@ -694,16 +694,58 @@
 ment',%0A%0A
+  requires: %5B 'foam.u2.HTMLValidator' %5D,%0A%0A
   export
@@ -902,22 +902,41 @@
     
-value: foam.u2
+factory: function() %7B return this
 .HTM
@@ -954,16 +954,18 @@
 create()
+ %7D
 %0A    %7D%0A 

Use a factory instead of creating an HTMLValidator inline.