2
0
Adam Shaw 8 жил өмнө
parent
commit
a6c97f269a

+ 1 - 1
src/Toolbar.ts

@@ -1,4 +1,4 @@
-import { htmlEscape } from './util'
+import { htmlEscape } from './util/html'
 import { htmlToElement, appendToElement, removeElement, findElements } from './util/dom'
 
 

+ 1 - 1
src/agenda/AgendaView.ts

@@ -4,8 +4,8 @@ import {
   uncompensateScroll,
   compensateScroll,
   subtractInnerElHeight,
-  htmlEscape,
 } from '../util'
+import { htmlEscape } from '../util/html'
 import { copyOwnProps } from '../util/object'
 import { findElements, createElement } from '../util/dom'
 import Scroller from '../common/Scroller'

+ 2 - 1
src/agenda/TimeGrid.ts

@@ -1,5 +1,6 @@
 import * as moment from 'moment'
-import { isInt, htmlEscape } from '../util'
+import { isInt } from '../util'
+import { htmlEscape } from '../util/html'
 import { divideDurationByDuration } from '../util/date'
 import { htmlToElement, findElements, createElement, removeElement, applyStyle } from '../util/dom'
 import InteractiveDateComponent from '../component/InteractiveDateComponent'

+ 1 - 1
src/agenda/TimeGridEventRenderer.ts

@@ -1,4 +1,4 @@
-import { htmlEscape, cssToStr } from '../util'
+import { htmlEscape, cssToStr } from '../util/html'
 import { removeElement, applyStyle } from '../util/dom'
 import EventRenderer from '../component/renderers/EventRenderer'
 

+ 2 - 2
src/basic/BasicView.ts

@@ -4,9 +4,9 @@ import {
   compensateScroll,
   subtractInnerElHeight,
   distributeHeight,
-  undistributeHeight,
-  htmlEscape
+  undistributeHeight
 } from '../util'
+import { htmlEscape } from '../util/html'
 import { createElement, findElements } from '../util/dom'
 import Scroller from '../common/Scroller'
 import View from '../View'

+ 1 - 1
src/basic/DayGrid.ts

@@ -1,4 +1,4 @@
-import { htmlEscape } from '../util'
+import { htmlEscape } from '../util/html'
 import { assignTo } from '../util/object'
 import CoordCache from '../common/CoordCache'
 import Popover from '../common/Popover'

+ 1 - 1
src/basic/DayGridEventRenderer.ts

@@ -1,4 +1,4 @@
-import { htmlEscape, cssToStr } from '../util'
+import { htmlEscape, cssToStr } from '../util/html'
 import { createElement, removeElement } from '../util/dom'
 import EventRenderer from '../component/renderers/EventRenderer'
 import DayGrid from './DayGrid'

+ 1 - 1
src/component/DateComponent.ts

@@ -1,5 +1,5 @@
 import * as moment from 'moment'
-import { attrsToStr, htmlEscape } from '../util'
+import { attrsToStr, htmlEscape } from '../util/html'
 import { dayIDs } from '../util/date'
 import momentExt from '../moment-ext'
 import { formatRange } from '../date-formatting'

+ 1 - 1
src/component/DayTableMixin.ts

@@ -1,4 +1,4 @@
-import { htmlEscape } from '../util'
+import { htmlEscape } from '../util/html'
 import { dayIDs } from '../util/date'
 import { prependToElement, appendToElement } from '../util/dom'
 import Mixin from '../common/Mixin'

+ 1 - 1
src/component/renderers/FillRenderer.ts

@@ -1,4 +1,4 @@
-import { cssToStr } from '../../util'
+import { cssToStr } from '../../util/html'
 import { htmlToElements, removeElement } from '../../util/dom'
 
 

+ 5 - 2
src/exports.ts

@@ -17,8 +17,6 @@ export {
   applyAll,
   debounce,
   isInt,
-  htmlEscape,
-  cssToStr,
   capitaliseFirstLetter,
   parseFieldSpecs,
   compareByFieldSpecs,
@@ -28,6 +26,11 @@ export {
   warn
 } from './util'
 
+export {
+  htmlEscape,
+  cssToStr
+} from './util/html'
+
 export {
   removeExact
 } from './util/array'

+ 1 - 1
src/list/ListEventRenderer.ts

@@ -1,4 +1,4 @@
-import { htmlEscape } from '../util'
+import { htmlEscape } from '../util/html'
 import EventRenderer from '../component/renderers/EventRenderer'
 import ListView from './ListView'
 

+ 2 - 1
src/list/ListView.ts

@@ -1,4 +1,5 @@
-import { htmlEscape, subtractInnerElHeight } from '../util'
+import { subtractInnerElHeight } from '../util'
+import { htmlEscape } from '../util/html'
 import { htmlToElement, createElement } from '../util/dom'
 import UnzonedRange from '../models/UnzonedRange'
 import View from '../View'

+ 1 - 1
src/locale.ts

@@ -1,7 +1,7 @@
 import * as moment from 'moment'
 import * as exportHooks from './exports'
 import { mergeOptions, globalDefaults, englishDefaults } from './options'
-import { stripHtmlEntities } from './util'
+import { stripHtmlEntities } from './util/html'
 
 export const localeOptionHash = {};
 (exportHooks as any).locales = localeOptionHash

+ 0 - 47
src/util.ts

@@ -313,53 +313,6 @@ export function firstDefined(...args) {
 }
 
 
-export function htmlEscape(s) {
-  return (s + '').replace(/&/g, '&')
-    .replace(/</g, '&lt;')
-    .replace(/>/g, '&gt;')
-    .replace(/'/g, '&#039;')
-    .replace(/"/g, '&quot;')
-    .replace(/\n/g, '<br />')
-}
-
-
-export function stripHtmlEntities(text) {
-  return text.replace(/&.*?;/g, '')
-}
-
-
-// Given a hash of CSS properties, returns a string of CSS.
-// Uses property names as-is (no camel-case conversion). Will not make statements for null/undefined values.
-export function cssToStr(cssProps) {
-  let statements = []
-
-  for (let name in cssProps) {
-    let val = cssProps[name]
-    if (val != null) {
-      statements.push(name + ':' + val)
-    }
-  }
-
-  return statements.join(';')
-}
-
-
-// Given an object hash of HTML attribute names to values,
-// generates a string that can be injected between < > in HTML
-export function attrsToStr(attrs) {
-  let parts = []
-
-  for (let name in attrs) {
-    let val = attrs[name]
-    if (val != null) {
-      parts.push(name + '="' + htmlEscape(val) + '"')
-    }
-  }
-
-  return parts.join(' ')
-}
-
-
 export function capitaliseFirstLetter(str) {
   return str.charAt(0).toUpperCase() + str.slice(1)
 }

+ 46 - 0
src/util/html.ts

@@ -0,0 +1,46 @@
+
+export function htmlEscape(s) {
+  return (s + '').replace(/&/g, '&amp;')
+    .replace(/</g, '&lt;')
+    .replace(/>/g, '&gt;')
+    .replace(/'/g, '&#039;')
+    .replace(/"/g, '&quot;')
+    .replace(/\n/g, '<br />')
+}
+
+
+export function stripHtmlEntities(text) {
+  return text.replace(/&.*?;/g, '')
+}
+
+
+// Given a hash of CSS properties, returns a string of CSS.
+// Uses property names as-is (no camel-case conversion). Will not make statements for null/undefined values.
+export function cssToStr(cssProps) {
+  let statements = []
+
+  for (let name in cssProps) {
+    let val = cssProps[name]
+    if (val != null) {
+      statements.push(name + ':' + val)
+    }
+  }
+
+  return statements.join(';')
+}
+
+
+// Given an object hash of HTML attribute names to values,
+// generates a string that can be injected between < > in HTML
+export function attrsToStr(attrs) {
+  let parts = []
+
+  for (let name in attrs) {
+    let val = attrs[name]
+    if (val != null) {
+      parts.push(name + '="' + htmlEscape(val) + '"')
+    }
+  }
+
+  return parts.join(' ')
+}