Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build polyfill for multiple environments
Browse files Browse the repository at this point in the history
Emanuel Tesar committed Sep 2, 2019
1 parent ae35e9e commit 2cfc6d1
Showing 15 changed files with 25 additions and 756 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
"env": {
"browser": true,
"jasmine": true,
"node": true,
"es6": true
},
"plugins": [
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@
node_modules/
local.log
browserstack.err
build/
4 changes: 2 additions & 2 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable require-jsdoc */
/* eslint-disable */
/**
* @license
* Copyright 2017 Google Inc. All Rights Reserved.
@@ -103,7 +103,7 @@ gulp.task('es5.api', function() {
.pipe(gulp.dest('dist/es5'));
});

gulp.task('es5.full', function(done) {
gulp.task('es5.full', function() {
return gulp.src([
'./src/**/*.js',
], {base: './'})
723 changes: 0 additions & 723 deletions dist/cjs/trustedtypes.api_only.js

This file was deleted.

2 changes: 1 addition & 1 deletion dist/es5/trustedtypes.api_only.build.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/es5/trustedtypes.build.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/es6/trustedtypes.api_only.build.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/es6/trustedtypes.build.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/spec/index.html
Original file line number Diff line number Diff line change
@@ -1213,7 +1213,7 @@
}
</style>
<link href="https://www.w3.org/StyleSheets/TR/2016/cg-draft" rel="stylesheet">
<meta content="Bikeshed version 450e0499b28bb4c684052ad936ad1e7d36c4eac5" name="generator">
<meta content="Bikeshed version 08c4b0e94d147852f66673459784d3429bb3bda1" name="generator">
<link href="https://wicg.github.io/trusted-types/dist/spec/" rel="canonical">
<style>/* style-md-lists */

@@ -1461,7 +1461,7 @@
<div class="head">
<p data-fill-with="logo"></p>
<h1 class="p-name no-ref" id="title">Trusted Types</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Draft Community Group Report, <time class="dt-updated" datetime="2019-08-11">11 August 2019</time></span></h2>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Draft Community Group Report, <time class="dt-updated" datetime="2019-09-02">2 September 2019</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
@@ -2471,7 +2471,7 @@ <h2 class="heading settled" data-level="4" id="integrations"><span class="secno"
<c- b>typedef</c-> (([<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#TreatNullAs" id="ref-for-TreatNullAs"><c- g>TreatNullAs</c-></a>=<a class="n" data-link-type="idl-name"><c- n>EmptyString</c-></a>] <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString②②"><c- b>DOMString</c-></a>) <c- b>or</c-> <a class="n" data-link-type="idl-name" href="#trustedhtml" id="ref-for-trustedhtml⑨"><c- n>TrustedHTML</c-></a>) <dfn class="dfn-paneled idl-code" data-dfn-type="typedef" data-export id="typedefdef-htmlstringdefaultsempty"><code><c- g>HTMLStringDefaultsEmpty</c-></code></dfn>;
</pre>
<p class="note" role="note"><span>Note:</span> <code class="idl"><a data-link-type="idl" href="#typedefdef-htmlstringdefaultsempty" id="ref-for-typedefdef-htmlstringdefaultsempty">HTMLStringDefaultsEmpty</a></code> is a non-nullable variant that accepts <em>null</em> on set.
Having this separate type allows <a href="https://heycam.github.io/webidl/#TreatNullAs">Web IDL §3.3.22 [TreatNullAs]</a> to attach to DOMString
Having this separate type allows <a href="https://heycam.github.io/webidl/#TreatNullAs">Web IDL §3.3.21 [TreatNullAs]</a> to attach to DOMString
per heycam/webidl#441.</p>
<p class="issue" id="issue-52d7d8d6"><a class="self-link" href="#issue-52d7d8d6"></a> <a href="https://heycam.github.io/webidl/#TreatNullAs">TreatNullAs=EmptyString</a> is confusing.
See note "It should not be used in specifications unless ...".
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/**
* @license
* Copyright 2017 Google Inc. All Rights Reserved.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@
"name": "trusted-types",
"version": "1.0.6",
"description": "Polyfill for the Trusted Types",
"main": "dist/cjs/trustedtypes.api_only.js",
"main": "build/cjs/trustedtypes.api_only.js",
"module": "build/esm/trustedtypes.api_only.js",
"directories": {
"test": "tests"
},
@@ -17,10 +18,11 @@
"test:localonly": "karma start --single-run --browsers ChromeHeadless,FirefoxHeadlessDev",
"karma": "karma start --browsers ChromeHeadless",
"karma:firefox": "karma start --browsers Firefox",
"build": "npm-run-all --parallel build:cjs build:es6 build:es5 --sequential sizereport",
"build:cjs": "rollup -c",
"build:es5": "gulp es5",
"build:es6": "gulp es6",
"build": "npm-run-all --parallel build:cjs --parallel build:dist-es5 build:dist-es6 --sequential sizereport",
"build:cjs": "rollup --file build/cjs/trustedtypes.api_only.js --format cjs --input src/polyfill/api_only.js",
"build:esm": "rollup --file build/esm/trustedtypes.api_only.js --format esm --input src/polyfill/api_only.js",
"build:dist-es5": "gulp es5",
"build:dist-es6": "gulp es6",
"spec": "gulp spec",
"sizereport": "gulp sizereport",
"add_build": "git add ./dist/"
15 changes: 0 additions & 15 deletions rollup.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/enforcer.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*/

/* eslint-disable no-unused-vars */
// TrustedTypeConfig is used only as jsdoc type
// eslint-disable-next-line
import {DIRECTIVE_NAME, TrustedTypeConfig} from './data/trustedtypeconfig.js';
import {
trustedTypes as TrustedTypes,
@@ -17,7 +18,6 @@ import {
} from
'./trustedtypes.js';

/* eslint-enable no-unused-vars */
import {installFunction, installSetter, installSetterAndGetter}
from './utils/wrapper.js';

2 changes: 2 additions & 0 deletions src/polyfill/api_only.js
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ const tt = trustedTypes;
function setupPolyfill() {
// We use array accessors to make sure Closure compiler will not alter the
// names of the properties..

// we only setup the polyfill only in browser environment.
if (typeof window === 'undefined') {
return;
}
4 changes: 2 additions & 2 deletions src/polyfill/full.js
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@
*/
import {TrustedTypesEnforcer} from '../enforcer.js';
import {TrustedTypeConfig} from '../data/trustedtypeconfig.js';
/* eslint-disable no-unused-vars */
import TrustedTypes from './api_only.js';
// import and setup trusted types
import './api_only.js';

/* eslint-enable no-unused-vars */

0 comments on commit 2cfc6d1

Please sign in to comment.