google-caja-sanitizer
Version:
Node wrapper for caja sanitizer for html/css including data-* attributes
1,528 lines (1,470 loc) • 165 kB
JavaScript
var window = {};
/* Copyright Google Inc.
* Licensed under the Apache Licence Version 2.0
* Autogenerated at Thu Sep 12 11:58:02 CDT 2013
* \@overrides window
* \@provides cssSchema, CSS_PROP_BIT_QUANTITY, CSS_PROP_BIT_HASH_VALUE, CSS_PROP_BIT_NEGATIVE_QUANTITY, CSS_PROP_BIT_QSTRING, CSS_PROP_BIT_URL, CSS_PROP_BIT_HISTORY_INSENSITIVE, CSS_PROP_BIT_UNRESERVED_WORD, CSS_PROP_BIT_UNICODE_RANGE, CSS_PROP_BIT_ALLOWED_IN_LINK, CSS_PROP_BIT_GLOBAL_NAME, CSS_PROP_BIT_PROPERTY_NAME */
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_QUANTITY = 1;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_HASH_VALUE = 2;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_NEGATIVE_QUANTITY = 4;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_QSTRING = 8;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_URL = 16;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_HISTORY_INSENSITIVE = 32;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_UNRESERVED_WORD = 64;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_UNICODE_RANGE = 128;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_ALLOWED_IN_LINK = 256;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_GLOBAL_NAME = 512;
/**
* @const
* @type {number}
*/
var CSS_PROP_BIT_PROPERTY_NAME = 1024;
var cssSchema = (function () {
var L = [ [ 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure',
'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet',
'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral',
'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue',
'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkkhaki',
'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred',
'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray',
'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray',
'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia',
'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green',
'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory',
'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon',
'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow',
'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen',
'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow',
'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine',
'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen',
'mediumslateblue', 'mediumspringgreen', 'mediumturquoise',
'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose',
'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab',
'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen',
'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru',
'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown',
'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen',
'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray',
'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato',
'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow',
'yellowgreen' ], [ 'all-scroll', 'col-resize', 'crosshair', 'default',
'e-resize', 'hand', 'help', 'move', 'n-resize', 'ne-resize', 'no-drop',
'not-allowed', 'nw-resize', 'pointer', 'progress', 'row-resize',
's-resize', 'se-resize', 'sw-resize', 'text', 'vertical-text',
'w-resize', 'wait' ], [ 'armenian', 'decimal', 'decimal-leading-zero',
'disc', 'georgian', 'lower-alpha', 'lower-greek', 'lower-latin',
'lower-roman', 'square', 'upper-alpha', 'upper-latin', 'upper-roman' ],
[ '100', '200', '300', '400', '500', '600', '700', '800', '900', 'bold',
'bolder', 'lighter' ], [ 'block-level', 'inline-level', 'table-caption',
'table-cell', 'table-column', 'table-column-group',
'table-footer-group', 'table-header-group', 'table-row',
'table-row-group' ], [ 'condensed', 'expanded', 'extra-condensed',
'extra-expanded', 'narrower', 'semi-condensed', 'semi-expanded',
'ultra-condensed', 'ultra-expanded', 'wider' ], [ 'inherit', 'inline',
'inline-block', 'inline-box', 'inline-flex', 'inline-grid',
'inline-list-item', 'inline-stack', 'inline-table', 'run-in' ], [
'behind', 'center-left', 'center-right', 'far-left', 'far-right',
'left-side', 'leftwards', 'right-side', 'rightwards' ], [ 'large',
'larger', 'small', 'smaller', 'x-large', 'x-small', 'xx-large',
'xx-small' ], [ 'dashed', 'dotted', 'double', 'groove', 'outset',
'ridge', 'solid' ], [ 'ease', 'ease-in', 'ease-in-out', 'ease-out',
'linear', 'step-end', 'step-start' ], [ 'at', 'closest-corner',
'closest-side', 'ellipse', 'farthest-corner', 'farthest-side' ], [
'baseline', 'middle', 'sub', 'super', 'text-bottom', 'text-top' ], [
'caption', 'icon', 'menu', 'message-box', 'small-caption', 'status-bar'
], [ 'fast', 'faster', 'slow', 'slower', 'x-fast', 'x-slow' ], [ 'above',
'below', 'higher', 'level', 'lower' ], [ 'cursive', 'fantasy',
'monospace', 'sans-serif', 'serif' ], [ 'loud', 'silent', 'soft',
'x-loud', 'x-soft' ], [ 'no-repeat', 'repeat-x', 'repeat-y', 'round',
'space' ], [ 'blink', 'line-through', 'overline', 'underline' ], [
'block', 'flex', 'grid', 'table' ], [ 'high', 'low', 'x-high', 'x-low'
], [ 'nowrap', 'pre', 'pre-line', 'pre-wrap' ], [ 'absolute', 'relative',
'static' ], [ 'alternate', 'alternate-reverse', 'reverse' ], [
'border-box', 'content-box', 'padding-box' ], [ 'capitalize',
'lowercase', 'uppercase' ], [ 'child', 'female', 'male' ], [ '=',
'opacity' ], [ 'backwards', 'forwards' ], [ 'bidi-override', 'embed' ],
[ 'bottom', 'top' ], [ 'break-all', 'keep-all' ], [ 'clip', 'ellipsis' ],
[ 'contain', 'cover' ], [ 'continuous', 'digits' ], [ 'end', 'start' ], [
'flat', 'preserve-3d' ], [ 'hide', 'show' ], [ 'inside', 'outside' ], [
'italic', 'oblique' ], [ 'left', 'right' ], [ 'ltr', 'rtl' ], [
'no-content', 'no-display' ], [ 'paused', 'running' ], [ 'suppress',
'unrestricted' ], [ 'thick', 'thin' ], [ ',' ], [ '/' ], [ 'all' ], [
'always' ], [ 'auto' ], [ 'avoid' ], [ 'both' ], [ 'break-word' ], [
'center' ], [ 'circle' ], [ 'code' ], [ 'collapse' ], [ 'contents' ], [
'fixed' ], [ 'hidden' ], [ 'infinite' ], [ 'inset' ], [ 'invert' ], [
'justify' ], [ 'list-item' ], [ 'local' ], [ 'medium' ], [ 'mix' ], [
'none' ], [ 'normal' ], [ 'once' ], [ 'repeat' ], [ 'scroll' ], [
'separate' ], [ 'small-caps' ], [ 'spell-out' ], [ 'to' ], [
'transparent' ], [ 'visible' ] ];
var schema = {
'animation': {
'cssPropBits': 517,
'cssLitGroup': [ L[ 10 ], L[ 24 ], L[ 29 ], L[ 44 ], L[ 47 ], L[ 53 ],
L[ 62 ], L[ 70 ], L[ 71 ] ],
'cssFns': [ 'cubic-bezier()', 'steps()' ]
},
'animation-delay': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 47 ] ],
'cssFns': [ ]
},
'animation-direction': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 24 ], L[ 47 ], L[ 71 ] ],
'cssFns': [ ]
},
'animation-duration': 'animation-delay',
'animation-fill-mode': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 29 ], L[ 47 ], L[ 53 ], L[ 70 ] ],
'cssFns': [ ]
},
'animation-iteration-count': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 47 ], L[ 62 ] ],
'cssFns': [ ]
},
'animation-name': {
'cssPropBits': 512,
'cssLitGroup': [ L[ 47 ], L[ 70 ] ],
'cssFns': [ ]
},
'animation-play-state': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 44 ], L[ 47 ] ],
'cssFns': [ ]
},
'animation-timing-function': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 10 ], L[ 47 ] ],
'cssFns': [ 'cubic-bezier()', 'steps()' ]
},
'azimuth': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 7 ], L[ 41 ], L[ 55 ] ],
'cssFns': [ ]
},
'backface-visibility': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 58 ], L[ 61 ], L[ 80 ] ],
'cssFns': [ ]
},
'background': {
'cssPropBits': 23,
'cssLitGroup': [ L[ 0 ], L[ 18 ], L[ 25 ], L[ 31 ], L[ 34 ], L[ 41 ],
L[ 47 ], L[ 48 ], L[ 51 ], L[ 55 ], L[ 60 ], L[ 67 ], L[ 70 ], L[ 73
], L[ 74 ], L[ 79 ] ],
'cssFns': [ 'image()', 'linear-gradient()', 'radial-gradient()',
'repeating-linear-gradient()', 'repeating-radial-gradient()',
'rgb()', 'rgba()' ]
},
'background-attachment': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 47 ], L[ 60 ], L[ 67 ], L[ 74 ] ],
'cssFns': [ ]
},
'background-color': {
'cssPropBits': 258,
'cssLitGroup': [ L[ 0 ], L[ 79 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'background-image': {
'cssPropBits': 16,
'cssLitGroup': [ L[ 47 ], L[ 70 ] ],
'cssFns': [ 'image()', 'linear-gradient()', 'radial-gradient()',
'repeating-linear-gradient()', 'repeating-radial-gradient()' ]
},
'background-position': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 31 ], L[ 41 ], L[ 47 ], L[ 55 ] ],
'cssFns': [ ]
},
'background-repeat': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 18 ], L[ 47 ], L[ 73 ] ],
'cssFns': [ ]
},
'border': {
'cssPropBits': 7,
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 46 ], L[ 61 ], L[ 63 ], L[ 68 ], L[
70 ], L[ 79 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'border-bottom': 'border',
'border-bottom-color': {
'cssPropBits': 2,
'cssLitGroup': [ L[ 0 ], L[ 79 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'border-bottom-left-radius': {
'cssPropBits': 5,
'cssFns': [ ]
},
'border-bottom-right-radius': 'border-bottom-left-radius',
'border-bottom-style': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 9 ], L[ 61 ], L[ 63 ], L[ 70 ] ],
'cssFns': [ ]
},
'border-bottom-width': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 46 ], L[ 68 ] ],
'cssFns': [ ]
},
'border-collapse': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 58 ], L[ 75 ] ],
'cssFns': [ ]
},
'border-color': 'border-bottom-color',
'border-left': 'border',
'border-left-color': 'border-bottom-color',
'border-left-style': 'border-bottom-style',
'border-left-width': 'border-bottom-width',
'border-radius': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 48 ] ],
'cssFns': [ ]
},
'border-right': 'border',
'border-right-color': 'border-bottom-color',
'border-right-style': 'border-bottom-style',
'border-right-width': 'border-bottom-width',
'border-spacing': 'border-bottom-left-radius',
'border-style': 'border-bottom-style',
'border-top': 'border',
'border-top-color': 'border-bottom-color',
'border-top-left-radius': 'border-bottom-left-radius',
'border-top-right-radius': 'border-bottom-left-radius',
'border-top-style': 'border-bottom-style',
'border-top-width': 'border-bottom-width',
'border-width': 'border-bottom-width',
'bottom': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 51 ] ],
'cssFns': [ ]
},
'box': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 59 ], L[ 70 ], L[ 71 ] ],
'cssFns': [ ]
},
'box-shadow': {
'cssPropBits': 7,
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 63 ], L[ 70 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'box-sizing': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 25 ] ],
'cssFns': [ ]
},
'caption-side': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 31 ] ],
'cssFns': [ ]
},
'clear': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 41 ], L[ 53 ], L[ 70 ] ],
'cssFns': [ ]
},
'clip': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 51 ] ],
'cssFns': [ 'rect()' ]
},
'color': {
'cssPropBits': 258,
'cssLitGroup': [ L[ 0 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'content': {
'cssPropBits': 8,
'cssLitGroup': [ L[ 70 ], L[ 71 ] ],
'cssFns': [ ]
},
'cue': {
'cssPropBits': 16,
'cssLitGroup': [ L[ 70 ] ],
'cssFns': [ ]
},
'cue-after': 'cue',
'cue-before': 'cue',
'cursor': {
'cssPropBits': 272,
'cssLitGroup': [ L[ 1 ], L[ 47 ], L[ 51 ] ],
'cssFns': [ ]
},
'direction': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 42 ] ],
'cssFns': [ ]
},
'display': {
'cssPropBits': 32,
'cssLitGroup': [ L[ 4 ], L[ 6 ], L[ 20 ], L[ 51 ], L[ 66 ], L[ 70 ] ],
'cssFns': [ ]
},
'display-extras': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 66 ], L[ 70 ] ],
'cssFns': [ ]
},
'display-inside': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 20 ], L[ 51 ] ],
'cssFns': [ ]
},
'display-outside': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 4 ], L[ 70 ] ],
'cssFns': [ ]
},
'elevation': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 15 ] ],
'cssFns': [ ]
},
'empty-cells': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 38 ] ],
'cssFns': [ ]
},
'filter': {
'cssPropBits': 32,
'cssFns': [ 'alpha()' ]
},
'float': {
'cssPropBits': 32,
'cssLitGroup': [ L[ 41 ], L[ 70 ] ],
'cssFns': [ ]
},
'font': {
'cssPropBits': 73,
'cssLitGroup': [ L[ 3 ], L[ 8 ], L[ 13 ], L[ 16 ], L[ 40 ], L[ 47 ], L[
48 ], L[ 68 ], L[ 71 ], L[ 76 ] ],
'cssFns': [ ]
},
'font-family': {
'cssPropBits': 72,
'cssLitGroup': [ L[ 16 ], L[ 47 ] ],
'cssFns': [ ]
},
'font-size': {
'cssPropBits': 1,
'cssLitGroup': [ L[ 8 ], L[ 68 ] ],
'cssFns': [ ]
},
'font-stretch': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 5 ], L[ 71 ] ],
'cssFns': [ ]
},
'font-style': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 40 ], L[ 71 ] ],
'cssFns': [ ]
},
'font-variant': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 71 ], L[ 76 ] ],
'cssFns': [ ]
},
'font-weight': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 3 ], L[ 71 ] ],
'cssFns': [ ]
},
'height': {
'cssPropBits': 37,
'cssLitGroup': [ L[ 51 ] ],
'cssFns': [ ]
},
'left': 'height',
'letter-spacing': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 71 ] ],
'cssFns': [ ]
},
'line-height': {
'cssPropBits': 1,
'cssLitGroup': [ L[ 71 ] ],
'cssFns': [ ]
},
'list-style': {
'cssPropBits': 16,
'cssLitGroup': [ L[ 2 ], L[ 39 ], L[ 56 ], L[ 70 ] ],
'cssFns': [ 'image()', 'linear-gradient()', 'radial-gradient()',
'repeating-linear-gradient()', 'repeating-radial-gradient()' ]
},
'list-style-image': {
'cssPropBits': 16,
'cssLitGroup': [ L[ 70 ] ],
'cssFns': [ 'image()', 'linear-gradient()', 'radial-gradient()',
'repeating-linear-gradient()', 'repeating-radial-gradient()' ]
},
'list-style-position': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 39 ] ],
'cssFns': [ ]
},
'list-style-type': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 2 ], L[ 56 ], L[ 70 ] ],
'cssFns': [ ]
},
'margin': 'bottom',
'margin-bottom': 'bottom',
'margin-left': 'bottom',
'margin-right': 'bottom',
'margin-top': 'bottom',
'max-height': {
'cssPropBits': 1,
'cssLitGroup': [ L[ 51 ], L[ 70 ] ],
'cssFns': [ ]
},
'max-width': 'max-height',
'min-height': {
'cssPropBits': 1,
'cssLitGroup': [ L[ 51 ] ],
'cssFns': [ ]
},
'min-width': 'min-height',
'opacity': {
'cssPropBits': 33,
'cssFns': [ ]
},
'outline': {
'cssPropBits': 7,
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 46 ], L[ 61 ], L[ 63 ], L[ 64 ], L[
68 ], L[ 70 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'outline-color': {
'cssPropBits': 2,
'cssLitGroup': [ L[ 0 ], L[ 64 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'outline-style': 'border-bottom-style',
'outline-width': 'border-bottom-width',
'overflow': {
'cssPropBits': 32,
'cssLitGroup': [ L[ 51 ], L[ 61 ], L[ 74 ], L[ 80 ] ],
'cssFns': [ ]
},
'overflow-wrap': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 54 ], L[ 71 ] ],
'cssFns': [ ]
},
'overflow-x': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 43 ], L[ 51 ], L[ 61 ], L[ 74 ], L[ 80 ] ],
'cssFns': [ ]
},
'overflow-y': 'overflow-x',
'padding': {
'cssPropBits': 1,
'cssFns': [ ]
},
'padding-bottom': 'opacity',
'padding-left': 'opacity',
'padding-right': 'opacity',
'padding-top': 'opacity',
'page-break-after': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 41 ], L[ 50 ], L[ 51 ], L[ 52 ] ],
'cssFns': [ ]
},
'page-break-before': 'page-break-after',
'page-break-inside': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 51 ], L[ 52 ] ],
'cssFns': [ ]
},
'pause': 'border-bottom-left-radius',
'pause-after': 'border-bottom-left-radius',
'pause-before': 'border-bottom-left-radius',
'perspective': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 70 ] ],
'cssFns': [ ]
},
'perspective-origin': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 31 ], L[ 41 ], L[ 55 ] ],
'cssFns': [ ]
},
'pitch': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 21 ], L[ 68 ] ],
'cssFns': [ ]
},
'pitch-range': 'border-bottom-left-radius',
'play-during': {
'cssPropBits': 16,
'cssLitGroup': [ L[ 51 ], L[ 69 ], L[ 70 ], L[ 73 ] ],
'cssFns': [ ]
},
'position': {
'cssPropBits': 32,
'cssLitGroup': [ L[ 23 ] ],
'cssFns': [ ]
},
'quotes': {
'cssPropBits': 8,
'cssLitGroup': [ L[ 70 ] ],
'cssFns': [ ]
},
'richness': 'border-bottom-left-radius',
'right': 'height',
'speak': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 70 ], L[ 71 ], L[ 77 ] ],
'cssFns': [ ]
},
'speak-header': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 50 ], L[ 72 ] ],
'cssFns': [ ]
},
'speak-numeral': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 35 ] ],
'cssFns': [ ]
},
'speak-punctuation': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 57 ], L[ 70 ] ],
'cssFns': [ ]
},
'speech-rate': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 14 ], L[ 68 ] ],
'cssFns': [ ]
},
'stress': 'border-bottom-left-radius',
'table-layout': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 51 ], L[ 60 ] ],
'cssFns': [ ]
},
'text-align': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 41 ], L[ 55 ], L[ 65 ] ],
'cssFns': [ ]
},
'text-decoration': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 19 ], L[ 70 ] ],
'cssFns': [ ]
},
'text-indent': 'border-bottom-left-radius',
'text-overflow': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 33 ] ],
'cssFns': [ ]
},
'text-shadow': 'box-shadow',
'text-transform': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 26 ], L[ 70 ] ],
'cssFns': [ ]
},
'text-wrap': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 45 ], L[ 70 ], L[ 71 ] ],
'cssFns': [ ]
},
'top': 'height',
'transform': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 70 ] ],
'cssFns': [ 'matrix()', 'perspective()', 'rotate()', 'rotate3d()',
'rotatex()', 'rotatey()', 'rotatez()', 'scale()', 'scale3d()',
'scalex()', 'scaley()', 'scalez()', 'skew()', 'skewx()', 'skewy()',
'translate()', 'translate3d()', 'translatex()', 'translatey()',
'translatez()' ]
},
'transform-origin': 'perspective-origin',
'transform-style': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 37 ] ],
'cssFns': [ ]
},
'transition': {
'cssPropBits': 1029,
'cssLitGroup': [ L[ 10 ], L[ 47 ], L[ 49 ], L[ 70 ] ],
'cssFns': [ 'cubic-bezier()', 'steps()' ]
},
'transition-delay': 'animation-delay',
'transition-duration': 'animation-delay',
'transition-property': {
'cssPropBits': 1024,
'cssLitGroup': [ L[ 47 ], L[ 49 ] ],
'cssFns': [ ]
},
'transition-timing-function': 'animation-timing-function',
'unicode-bidi': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 30 ], L[ 71 ] ],
'cssFns': [ ]
},
'vertical-align': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 12 ], L[ 31 ] ],
'cssFns': [ ]
},
'visibility': {
'cssPropBits': 32,
'cssLitGroup': [ L[ 58 ], L[ 61 ], L[ 80 ] ],
'cssFns': [ ]
},
'voice-family': {
'cssPropBits': 8,
'cssLitGroup': [ L[ 27 ], L[ 47 ] ],
'cssFns': [ ]
},
'volume': {
'cssPropBits': 1,
'cssLitGroup': [ L[ 17 ], L[ 68 ] ],
'cssFns': [ ]
},
'white-space': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 22 ], L[ 71 ] ],
'cssFns': [ ]
},
'width': {
'cssPropBits': 33,
'cssLitGroup': [ L[ 51 ] ],
'cssFns': [ ]
},
'word-break': {
'cssPropBits': 0,
'cssLitGroup': [ L[ 32 ], L[ 71 ] ],
'cssFns': [ ]
},
'word-spacing': 'letter-spacing',
'word-wrap': 'overflow-wrap',
'z-index': 'bottom',
'zoom': 'line-height',
'cubic-bezier()': 'animation-delay',
'steps()': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 36 ], L[ 47 ] ],
'cssFns': [ ]
},
'image()': {
'cssPropBits': 18,
'cssLitGroup': [ L[ 0 ], L[ 47 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'linear-gradient()': {
'cssPropBits': 7,
'cssLitGroup': [ L[ 0 ], L[ 31 ], L[ 41 ], L[ 47 ], L[ 78 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'radial-gradient()': {
'cssPropBits': 7,
'cssLitGroup': [ L[ 0 ], L[ 11 ], L[ 31 ], L[ 41 ], L[ 47 ], L[ 55 ],
L[ 56 ] ],
'cssFns': [ 'rgb()', 'rgba()' ]
},
'repeating-linear-gradient()': 'linear-gradient()',
'repeating-radial-gradient()': 'radial-gradient()',
'rgb()': {
'cssPropBits': 1,
'cssLitGroup': [ L[ 47 ] ],
'cssFns': [ ]
},
'rgba()': 'rgb()',
'rect()': {
'cssPropBits': 5,
'cssLitGroup': [ L[ 47 ], L[ 51 ] ],
'cssFns': [ ]
},
'alpha()': {
'cssPropBits': 1,
'cssLitGroup': [ L[ 28 ] ],
'cssFns': [ ]
},
'matrix()': 'animation-delay',
'perspective()': 'border-bottom-left-radius',
'rotate()': 'border-bottom-left-radius',
'rotate3d()': 'animation-delay',
'rotatex()': 'border-bottom-left-radius',
'rotatey()': 'border-bottom-left-radius',
'rotatez()': 'border-bottom-left-radius',
'scale()': 'animation-delay',
'scale3d()': 'animation-delay',
'scalex()': 'border-bottom-left-radius',
'scaley()': 'border-bottom-left-radius',
'scalez()': 'border-bottom-left-radius',
'skew()': 'animation-delay',
'skewx()': 'border-bottom-left-radius',
'skewy()': 'border-bottom-left-radius',
'translate()': 'animation-delay',
'translate3d()': 'animation-delay',
'translatex()': 'border-bottom-left-radius',
'translatey()': 'border-bottom-left-radius',
'translatez()': 'border-bottom-left-radius'
};
if (true) {
for (var key in schema) {
if ('string' === typeof schema[ key ] &&
Object.hasOwnProperty.call(schema, key)) {
schema[ key ] = schema[ schema[ key ] ];
}
}
}
return schema;
})();
if (typeof window !== 'undefined') {
window['cssSchema'] = cssSchema;
}
;
// Copyright (C) 2011 Google Inc.
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* A lexical scannar for CSS3 as defined at http://www.w3.org/TR/css3-syntax .
*
* @author Mike Samuel <mikesamuel@gmail.com>
* \@provides lexCss, decodeCss
* \@overrides window
*/
var lexCss;
var decodeCss;
(function () {
/**
* Decodes an escape sequence as specified in CSS3 section 4.1.
* http://www.w3.org/TR/css3-syntax/#characters
* @private
*/
function decodeCssEscape(s) {
var i = parseInt(s.substring(1), 16);
// If parseInt didn't find a hex diigt, it returns NaN so return the
// escaped character.
// Otherwise, parseInt will stop at the first non-hex digit so there's no
// need to worry about trailing whitespace.
if (i > 0xffff) {
// A supplemental codepoint.
return i -= 0x10000,
String.fromCharCode(
0xd800 + (i >> 10),
0xdc00 + (i & 0x3FF));
} else if (i == i) {
return String.fromCharCode(i);
} else if (s[1] < ' ') {
// "a backslash followed by a newline is ignored".
return '';
} else {
return s[1];
}
}
/**
* Returns an equivalent CSS string literal given plain text: foo -> "foo".
* @private
*/
function escapeCssString(s, replacer) {
return '"' + s.replace(/[\u0000-\u001f\\\"<>]/g, replacer) + '"';
}
/**
* Maps chars to CSS escaped equivalents: "\n" -> "\\a ".
* @private
*/
function escapeCssStrChar(ch) {
return cssStrChars[ch]
|| (cssStrChars[ch] = '\\' + ch.charCodeAt(0).toString(16) + ' ');
}
/**
* Maps chars to URI escaped equivalents: "\n" -> "%0a".
* @private
*/
function escapeCssUrlChar(ch) {
return cssUrlChars[ch]
|| (cssUrlChars[ch] = (ch < '\x10' ? '%0' : '%')
+ ch.charCodeAt(0).toString(16));
}
/**
* Mapping of CSS special characters to escaped equivalents.
* @private
*/
var cssStrChars = {
'\\': '\\\\'
};
/**
* Mapping of CSS special characters to URL-escaped equivalents.
* @private
*/
var cssUrlChars = {
'\\': '%5c'
};
// The comments below are copied from the CSS3 module syntax at
// http://www.w3.org/TR/css3-syntax .
// These string constants minify out when this is run-through closure
// compiler.
// Rules that have been adapted have comments prefixed with "Diff:", and
// where rules have been combined to avoid back-tracking in the regex engine
// or to work around limitations, there is a comment prefixed with
// "NewRule:".
// In the below, we assume CRLF and CR have been normalize to CR.
// wc ::= #x9 | #xA | #xC | #xD | #x20
var WC = '[\\t\\n\\f ]';
// w ::= wc*
var W = WC + '*';
// nl ::= #xA | #xD #xA | #xD | #xC
var NL = '[\\n\\f]';
// nonascii ::= [#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF]
// NewRule: Supplemental codepoints are represented as surrogate pairs in JS.
var SURROGATE_PAIR = '[\\ud800-\\udbff][\\udc00-\\udfff]';
var NONASCII = '[\\u0080-\\ud7ff\\ue000-\\ufffd]|' + SURROGATE_PAIR;
// unicode ::= '\' [0-9a-fA-F]{1,6} wc?
// NewRule: No point in having ESCAPE do (\\x|\\y)
var UNICODE_TAIL = '[0-9a-fA-F]{1,6}' + WC + '?';
var UNICODE = '\\\\' + UNICODE_TAIL;
// escape ::= unicode
// | '\' [#x20-#x7E#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF]
// NewRule: Below we use escape tail to efficiently match an escape or a
// line continuation so we can decode string content.
var ESCAPE_TAIL = '(?:' + UNICODE_TAIL
+ '|[\\u0020-\\u007e\\u0080-\\ud7ff\\ue000\\ufffd]|'
+ SURROGATE_PAIR + ')';
var ESCAPE = '\\\\' + ESCAPE_TAIL;
// urlchar ::= [#x9#x21#x23-#x26#x28-#x7E] | nonascii | escape
var URLCHAR = '(?:[\\t\\x21\\x23-\\x26\\x28-\\x5b\\x5d-\\x7e]|'
+ NONASCII + '|' + ESCAPE + ')';
// stringchar ::= urlchar | #x20 | '\' nl
// We ignore mismatched surrogate pairs inside strings, so stringchar
// simplifies to a non-(quote|newline|backslash) or backslash any.
// Since we normalize CRLF to a single code-unit, there is no special
// handling needed for '\\' + CRLF.
var STRINGCHAR = '[^\'"\\n\\f\\\\]|\\\\[\\s\\S]';
// string ::= '"' (stringchar | "'")* '"' | "'" (stringchar | '"')* "'"
var STRING = '"(?:\'|' + STRINGCHAR + ')*"'
+ '|\'(?:\"|' + STRINGCHAR + ')*\'';
// num ::= [0-9]+ | [0-9]* '.' [0-9]+
// Diff: We attach signs to num tokens.
var NUM = '[-+]?(?:[0-9]+(?:[.][0-9]+)?|[.][0-9]+)';
// nmstart ::= [a-zA-Z] | '_' | nonascii | escape
var NMSTART = '(?:[a-zA-Z_]|' + NONASCII + '|' + ESCAPE + ')';
// nmchar ::= [a-zA-Z0-9] | '-' | '_' | nonascii | escape
var NMCHAR = '(?:[a-zA-Z0-9_-]|' + NONASCII + '|' + ESCAPE + ')';
// name ::= nmchar+
var NAME = NMCHAR + '+';
// ident ::= '-'? nmstart nmchar*
var IDENT = '-?' + NMSTART + NMCHAR + '*';
// ATKEYWORD ::= '@' ident
var ATKEYWORD = '@' + IDENT;
// HASH ::= '#' name
var HASH = '#' + NAME;
// NUMBER ::= num
var NUMBER = NUM;
// NewRule: union of IDENT, ATKEYWORD, HASH, but excluding #[0-9].
var WORD_TERM = '(?:@?-?' + NMSTART + '|#)' + NMCHAR + '*';
// PERCENTAGE ::= num '%'
var PERCENTAGE = NUM + '%';
// DIMENSION ::= num ident
var DIMENSION = NUM + IDENT;
var NUMERIC_VALUE = NUM + '(?:%|' + IDENT + ')?';
// URI ::= "url(" w (string | urlchar* ) w ")"
var URI = 'url[(]' + W + '(?:' + STRING + '|' + URLCHAR + '*)' + W + '[)]';
// UNICODE-RANGE ::= "U+" [0-9A-F?]{1,6} ('-' [0-9A-F]{1,6})?
var UNICODE_RANGE = 'U[+][0-9A-F?]{1,6}(?:-[0-9A-F]{1,6})?';
// CDO ::= "<\!--"
var CDO = '<\!--';
// CDC ::= "-->"
var CDC = '-->';
// S ::= wc+
var S = WC + '+';
// COMMENT ::= "/*" [^*]* '*'+ ([^/] [^*]* '*'+)* "/"
// Diff: recognizes // comments.
var COMMENT = '/(?:[*][^*]*[*]+(?:[^/][^*]*[*]+)*/|/[^\\n\\f]*)';
// FUNCTION ::= ident '('
// Diff: We exclude url explicitly.
// TODO: should we be tolerant of "fn ("?
var FUNCTION = '(?!url[(])' + IDENT + '[(]';
// INCLUDES ::= "~="
var INCLUDES = '~=';
// DASHMATCH ::= "|="
var DASHMATCH = '[|]=';
// PREFIXMATCH ::= "^="
var PREFIXMATCH = '[^]=';
// SUFFIXMATCH ::= "$="
var SUFFIXMATCH = '[$]=';
// SUBSTRINGMATCH ::= "*="
var SUBSTRINGMATCH = '[*]=';
// NewRule: one rule for all the comparison operators.
var CMP_OPS = '[~|^$*]=';
// CHAR ::= any character not matched by the above rules, except for " or '
// Diff: We exclude / and \ since they are handled above to prevent
// /* without a following */ from combining when comments are concatenated.
var CHAR = '[^"\'\\\\/]|/(?![/*])';
// BOM ::= #xFEFF
var BOM = '\\uFEFF';
var CSS_TOKEN = new RegExp([
BOM, UNICODE_RANGE, URI, FUNCTION, WORD_TERM, STRING, NUMERIC_VALUE,
CDO, CDC, S, COMMENT, CMP_OPS, CHAR].join("|"), 'gi');
var CSS_DECODER = new RegExp('\\\\(?:' + ESCAPE_TAIL + '|' + NL + ')', 'g');
var URL_RE = new RegExp('^url\\(' + W + '["\']?|["\']?' + W + '\\)$', 'gi');
/**
* Decodes CSS escape sequences in a CSS string body.
*/
decodeCss = function (css) {
return css.replace(CSS_DECODER, decodeCssEscape);
};
/**
* Given CSS Text, returns an array of normalized tokens.
* @param {string} cssText
* @return {Array.<string>} tokens where all ignorable token sequences have
* been reduced to a single {@code " "} and all strings and
* {@code url(...)} tokens have been normalized to use double quotes as
* delimiters and to not otherwise contain double quotes.
*/
lexCss = function (cssText) {
cssText = '' + cssText;
var tokens = cssText.replace(/\r\n?/g, '\n') // Normalize CRLF & CR to LF.
.match(CSS_TOKEN) || [];
var j = 0;
var last = ' ';
for (var i = 0, n = tokens.length; i < n; ++i) {
// Normalize all escape sequences. We will have to re-escape some
// codepoints in string and url(...) bodies but we already know the
// boundaries.
// We might mistakenly treat a malformed identifier like \22\20\22 as a
// string, but that will not break any valid stylesheets since we requote
// and re-escape in string below.
var tok = decodeCss(tokens[i]);
var len = tok.length;
var cc = tok.charCodeAt(0);
tok =
// All strings should be double quoted, and the body should never
// contain a double quote.
(cc == '"'.charCodeAt(0) || cc == '\''.charCodeAt(0))
? escapeCssString(tok.substring(1, len - 1), escapeCssStrChar)
// A breaking ignorable token should is replaced with a single space.
: (cc == '/'.charCodeAt(0) && len > 1 // Comment.
|| tok == '\\' || tok == CDC || tok == CDO || tok == '\ufeff'
// Characters in W.
|| cc <= ' '.charCodeAt(0))
? ' '
// Make sure that all url(...)s are double quoted.
: /url\(/i.test(tok)
? 'url(' + escapeCssString(
tok.replace(URL_RE, ''),
escapeCssUrlChar)
+ ')'
// Escapes in identifier like tokens will have been normalized above.
: tok;
// Merge adjacent space tokens.
if (last != tok || tok != ' ') {
tokens[j++] = last = tok;
}
}
tokens.length = j;
return tokens;
};
})();
// Exports for closure compiler.
if (typeof window !== 'undefined') {
window['lexCss'] = lexCss;
window['decodeCss'] = decodeCss;
}
;
// Copyright (C) 2010 Google Inc.
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview
* Implements RFC 3986 for parsing/formatting URIs.
*
* @author mikesamuel@gmail.com
* \@provides URI
* \@overrides window
*/
var URI = (function () {
/**
* creates a uri from the string form. The parser is relaxed, so special
* characters that aren't escaped but don't cause ambiguities will not cause
* parse failures.
*
* @return {URI|null}
*/
function parse(uriStr) {
var m = ('' + uriStr).match(URI_RE_);
if (!m) { return null; }
return new URI(
nullIfAbsent(m[1]),
nullIfAbsent(m[2]),
nullIfAbsent(m[3]),
nullIfAbsent(m[4]),
nullIfAbsent(m[5]),
nullIfAbsent(m[6]),
nullIfAbsent(m[7]));
}
/**
* creates a uri from the given parts.
*
* @param scheme {string} an unencoded scheme such as "http" or null
* @param credentials {string} unencoded user credentials or null
* @param domain {string} an unencoded domain name or null
* @param port {number} a port number in [1, 32768].
* -1 indicates no port, as does null.
* @param path {string} an unencoded path
* @param query {Array.<string>|string|null} a list of unencoded cgi
* parameters where even values are keys and odds the corresponding values
* or an unencoded query.
* @param fragment {string} an unencoded fragment without the "#" or null.
* @return {URI}
*/
function create(scheme, credentials, domain, port, path, query, fragment) {
var uri = new URI(
encodeIfExists2(scheme, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),
encodeIfExists2(
credentials, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),
encodeIfExists(domain),
port > 0 ? port.toString() : null,
encodeIfExists2(path, URI_DISALLOWED_IN_PATH_),
null,
encodeIfExists(fragment));
if (query) {
if ('string' === typeof query) {
uri.setRawQuery(query.replace(/[^?&=0-9A-Za-z_\-~.%]/g, encodeOne));
} else {
uri.setAllParameters(query);
}
}
return uri;
}
function encodeIfExists(unescapedPart) {
if ('string' == typeof unescapedPart) {
return encodeURIComponent(unescapedPart);
}
return null;
};
/**
* if unescapedPart is non null, then escapes any characters in it that aren't
* valid characters in a url and also escapes any special characters that
* appear in extra.
*
* @param unescapedPart {string}
* @param extra {RegExp} a character set of characters in [\01-\177].
* @return {string|null} null iff unescapedPart == null.
*/
function encodeIfExists2(unescapedPart, extra) {
if ('string' == typeof unescapedPart) {
return encodeURI(unescapedPart).replace(extra, encodeOne);
}
return null;
};
/** converts a character in [\01-\177] to its url encoded equivalent. */
function encodeOne(ch) {
var n = ch.charCodeAt(0);
return '%' + '0123456789ABCDEF'.charAt((n >> 4) & 0xf) +
'0123456789ABCDEF'.charAt(n & 0xf);
}
/**
* {@updoc
* $ normPath('foo/./bar')
* # 'foo/bar'
* $ normPath('./foo')
* # 'foo'
* $ normPath('foo/.')
* # 'foo'
* $ normPath('foo//bar')
* # 'foo/bar'
* }
*/
function normPath(path) {
return path.replace(/(^|\/)\.(?:\/|$)/g, '$1').replace(/\/{2,}/g, '/');
}
var PARENT_DIRECTORY_HANDLER = new RegExp(
''
// A path break
+ '(/|^)'
// followed by a non .. path element
// (cannot be . because normPath is used prior to this RegExp)
+ '(?:[^./][^/]*|\\.{2,}(?:[^./][^/]*)|\\.{3,}[^/]*)'
// followed by .. followed by a path break.
+ '/\\.\\.(?:/|$)');
var PARENT_DIRECTORY_HANDLER_RE = new RegExp(PARENT_DIRECTORY_HANDLER);
var EXTRA_PARENT_PATHS_RE = /^(?:\.\.\/)*(?:\.\.$)?/;
/**
* Normalizes its input path and collapses all . and .. sequences except for
* .. sequences that would take it above the root of the current parent
* directory.
* {@updoc
* $ collapse_dots('foo/../bar')
* # 'bar'
* $ collapse_dots('foo/./bar')
* # 'foo/bar'
* $ collapse_dots('foo/../bar/./../../baz')
* # 'baz'
* $ collapse_dots('../foo')
* # '../foo'
* $ collapse_dots('../foo').replace(EXTRA_PARENT_PATHS_RE, '')
* # 'foo'
* }
*/
function collapse_dots(path) {
if (path === null) { return null; }
var p = normPath(path);
// Only /../ left to flatten
var r = PARENT_DIRECTORY_HANDLER_RE;
// We replace with $1 which matches a / before the .. because this
// guarantees that:
// (1) we have at most 1 / between the adjacent place,
// (2) always have a slash if there is a preceding path section, and
// (3) we never turn a relative path into an absolute path.
for (var q; (q = p.replace(r, '$1')) != p; p = q) {};
return p;
}
/**
* resolves a relative url string to a base uri.
* @return {URI}
*/
function resolve(baseUri, relativeUri) {
// there are several kinds of relative urls:
// 1. //foo - replaces everything from the domain on. foo is a domain name
// 2. foo - replaces the last part of the path, the whole query and fragment
// 3. /foo - replaces the the path, the query and fragment
// 4. ?foo - replace the query and fragment
// 5. #foo - replace the fragment only
var absoluteUri = baseUri.clone();
// we satisfy these conditions by looking for the first part of relativeUri
// that is not blank and applying defaults to the rest
var overridden = relativeUri.hasScheme();
if (overridden) {
absoluteUri.setRawScheme(relativeUri.getRawScheme());
} else {
overridden = relativeUri.hasCredentials();
}
if (overridden) {
absoluteUri.setRawCredentials(relativeUri.getRawCredentials());
} else {
overridden = relativeUri.hasDomain();
}
if (overridden) {
absoluteUri.setRawDomain(relativeUri.getRawDomain());
} else {
overridden = relativeUri.hasPort();
}
var rawPath = relativeUri.getRawPath();
var simplifiedPath = collapse_dots(rawPath);
if (overridden) {
absoluteUri.setPort(relativeUri.getPort());
simplifiedPath = simplifiedPath
&& simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
} else {
overridden = !!rawPath;
if (overridden) {
// resolve path properly
if (simplifiedPath.charCodeAt(0) !== 0x2f /* / */) { // path is relative
var absRawPath = collapse_dots(absoluteUri.getRawPath() || '')
.replace(EXTRA_PARENT_PATHS_RE, '');
var slash = absRawPath.lastIndexOf('/') + 1;
simplifiedPath = collapse_dots(
(slash ? absRawPath.substring(0, slash) : '')
+ collapse_dots(rawPath))
.replace(EXTRA_PARENT_PATHS_RE, '');
}
} else {
simplifiedPath = simplifiedPath
&& simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
if (simplifiedPath !== rawPath) {
absoluteUri.setRawPath(simplifiedPath);
}
}
}
if (overridden) {
absoluteUri.setRawPath(simplifiedPath);
} else {
overridden = relativeUri.hasQuery();
}
if (overridden) {
absoluteUri.setRawQuery(relativeUri.getRawQuery());
} else {
overridden = relativeUri.hasFragment();
}
if (overridden) {
absoluteUri.setRawFragment(relativeUri.getRawFragment());
}
return absoluteUri;
}
/**
* a mutable URI.
*
* This class contains setters and getters for the parts of the URI.
* The <tt>getXYZ</tt>/<tt>setXYZ</tt> methods return the decoded part -- so
* <code>uri.parse('/foo%20bar').getPath()</code> will return the decoded path,
* <tt>/foo bar</tt>.
*
* <p>The raw versions of fields are available too.
* <code>uri.parse('/foo%20bar').getRawPath()</code> will return the raw path,
* <tt>/foo%20bar</tt>. Use the raw setters with care, since
* <code>URI::toString</code> is not guaranteed to return a valid url if a
* raw setter was used.
*
* <p>All setters return <tt>this</tt> and so may be chained, a la
* <code>uri.parse('/foo').setFragment('part').toString()</code>.
*
* <p>You should not use this constructor directly -- please prefer the factory
* functions {@link uri.parse}, {@link uri.create}, {@link uri.resolve}
* instead.</p>
*
* <p>The parameters are all raw (assumed to be properly escaped) parts, and
* any (but not all) may be null. Undefined is not allowed.</p>
*
* @constructor
*/
function URI(
rawScheme,
rawCredentials, rawDomain, port,
rawPath, rawQuery, rawFragment) {
this.scheme_ = rawScheme;
this.credentials_ = rawCredentials;
this.domain_ = rawDomain;
this.port_ = port;
this.path_ = rawPath;
this.query_ = rawQuery;
this.fragment_ = rawFragment;
/**
* @type {Array|null}
*/
this.paramCache_ = null;
}
/** returns the string form of the url. */
URI.prototype.toString = function () {
var out = [];
if (null !== this.scheme_) { out.push(this.scheme_, ':'); }
if (null !== this.domain_) {
out.push('//');
if (null !== this.credentials_) { out.push(this.credentials_, '@'); }
out.push(this.domain_);
if (null !== this.port_) { out.push(':', this.port_.toString()); }
}
if (null !== this.path_) { out.push(this.path_); }
if (null !== this.query_) { out.push('?', this.query_); }
if (null !== this.fragment_) { out.push('#', this.fragment_); }
return out.join('');
};
URI.prototype.clone = function () {
return new URI(this.scheme_, this.credentials_, this.domain_, this.port_,
this.path_, this.query_, this.fragment_);
};
URI.prototype.getScheme = function () {
// HTML5 spec does not require the scheme to be lowercased but
// all common browsers except Safari lowercase the scheme.
return this.scheme_ && decodeURIComponent(this.scheme_).toLowerCase();
};
URI.prototype.getRawScheme = function () {
return this.scheme_;
};
URI.prototype.setScheme = function (newScheme) {
this.scheme_ = encodeIfExists2(
newScheme, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_);
return this;
};
URI.prototype.setRawScheme = function (newScheme) {
this.scheme_ = newScheme ? newScheme : null;
return this;
};
URI.prototype.hasScheme = function () {
return null !== this.scheme_;
};
URI.prototype.getCredentials = function () {
return this.credentials_ && decodeURIComponent(this.credentials_);
};
URI.prototype.getRawCredentials = function () {
return this.credentials_;
};
URI.prototype.setCredentials = function (newCredentials) {
this.credentials_ = encodeIfExists2(
newCredentials, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_);
return this;
};
URI.prototype.setRawCredentials = function (newCredentials) {
this.credentials_ = newCredentials ? newCredentials : null;
return this;
};
URI.prototype.hasCredentials = function () {
return null !== this.credentials_;
};
URI.prototype.getDomain = function () {
return this.domain_ && decodeURIComponent(this.domain_);
};
URI.prototype.getRawDomain = function () {
return this.domain_;
};
URI.prototype.setDomain = function (newDomain) {
return this.setRawDomain(newDomain && encodeURIComponent(newDomain));
};
URI.prototype.setRawDomain = function (newDomain) {
this.domain_ = newDomain ? newDomain : null;
// Maintain the invariant that paths must start with a slash when the URI
// is not path-relative.
return this.setRawPath(this.path_);
};
URI.prototype.hasDomain = function () {
return null !== this.domain_;
};
URI.prototype.getPort = function () {
return this.port_ && decodeURIComponent(this.port_);
};
URI.prototype.setPort = function (newPort) {
if (newPort) {
newPort = Number(newPort);
if (newPort !== (newPort & 0xffff)) {
throw new Error('Bad port number ' + newPort);
}
this.port_ = '' + newPort;
} else {
this.port_ = null;
}
return this;
};
URI.prototype.hasPort = function () {
return null !== this.port_;
};
URI.prototype.getPath = function () {
return this.path_ && decodeURIComponent(this.path_);
};
URI.prototype.getRawPath = function () {
return this.path_;
};
URI.prototype.setPath = function (newPath) {
return this.setRawPath(encodeIfExists2(newPath, URI_DISALLOWED_IN_PATH_));
};
URI.prototype.setRawPath = function (newPath) {
if (newPath) {
newPath = String(newPath);
this.path_ =
// Paths must start with '/' unless this is a path-relative URL.
(!this.domain_ || /^\//.test(newPath)) ? newPath : '/' + newPath;
} else {
this.path_ = null;
}
return this;
};
URI.prototype.hasPath = function () {
return null !== this.path_;
};
URI.prototype.getQuery = function () {
// From http://www.w3.org/Addressing/URL/4_URI_Recommentations.html
// Within the query string, the plus sign is reserved as shorthand notation
// for a space.
return this.query_ && decodeURIComponent(this.query_).replace(/\+/g, ' ');
};
URI.prototype.getRawQuery = function () {
return this.query_;
};
URI.prototype.setQuery = function (newQuery) {
this.paramCache_ = null;
this.query_ = encodeIfExists(newQuery);
return this;
};
URI.prototype.setRawQuery = function (newQuery) {
this.paramCache_ = null;
this.query_ = newQuery ? newQuery : null;
return this;
};
URI.prototype.hasQuery = function () {
return null !== this.query_;
};
/**
* sets the query given a list of strings of the form
* [ key0, value0, key1, value1, ... ].
*
* <p><code>uri.setAllParameters(['a', 'b', 'c', 'd']).getQuery()</code>
* will yield <code>'a=b&c=d'</code>.
*/
URI.prototype.setAllParameters = function (params) {
if (typeof params === 'object') {
if (!(params instanceof Array)
&& (params instanceof Object
|| Object.prototype.toString.call(params) !== '[object Array]')) {
var newParams = [];
var i = -1;
for (var k in params) {
var v = params[k];
if ('string' === typeof v) {
newParams[++i] = k;
newParams[++i] = v;
}
}
params = newParams;
}
}
this.paramCache_ = null;
var queryBuf = [];
var separator = '';
for (var j = 0; j < params.length;) {
var k = params[j++];
var v = params[j++];
queryBuf.push(separator, encodeURIComponent(k.toString()));
separator = '&';
if (v) {
queryBuf.push('=', encodeURIComponent(v.toString()));
}