Compartilhar via


WinJS.Utilities.requireSupportedForProcessing function

Asserts that the value is compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll. If the value is not compatible, and strictProcessing is on, an exception is thrown.

All functions that have been declared using WinJS.Class.define, WinJS.Class.derive, WinJS.UI.Pages.define, or WinJS.Binding.converter are automatically marked as supported for declarative processing. Any other function that you use from a declarative context (that is, a context in which an HTML element has a data-win-control or data-win-options attribute) must be marked manually by calling this function. When you mark a function as supported for declarative processing, you are guaranteeing that the code in the function is secure from injection of third-party content.

Syntax

var object = WinJS.Utilities.requireSupportedForProcessing(value);

Parameters

  • value
    Type: Object

    The value to be tested for compatibility with declarative processing. If the value is a function it must be marked with a property supportedForProcessing with a value of true when strictProcessing is on. For more information, see WinJS.Utilities.markSupportedForProcessing.

Return value

Type: Object

The input value.

Examples

The following code shows how to use this function. If randomizeValue had not been set with WinJS.Utilities.markSupportedForProcessing, requireSupportedForProcessing would throw an exception.

function randomizeValue() {
     var value = Math.floor((Math.random() * 1000) % 8);
     if (value < 0)
          value = 0;
     else if (value > 9)
          value = 9;
      return value;
}

WinJS.Utilities.markSupportedForProcessing(randomizeValue);

WinJS.Utilities.requireSupportedForProcessing(randomizeValue);

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.Utilities