From 9d4b65fe191b092336205ec8b0ef2c9fcb520112 Mon Sep 17 00:00:00 2001 From: Maksim Chemerisuk Date: Sat, 17 Nov 2018 11:33:30 +0300 Subject: [PATCH] extract dateinput-picker LE --- .travis.yml | 1 + src/main.js | 39 +++++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index b319319..79cdfa9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,4 @@ cache: before_install: - npm install better-dom@latest - npm install -g gulp +install: npm install diff --git a/src/main.js b/src/main.js index 4b5d30c..c890cb2 100644 --- a/src/main.js +++ b/src/main.js @@ -158,25 +158,12 @@ table+table[aria-hidden=true] { this._svgTextFont = this.css("font"); this._svgTextOffset = ["padding-left", "border-left-width", "text-indent"].map(p => parseFloat(this.css(p))).reduce((a, b) => a + b); - const picker = DOM.create(""); - const object = DOM.create("")[0]; - object.type = "text/html"; - object.width = "100%"; - object.height = "100%"; - object.onload = this._initPicker.bind(this, object, picker); - // non-IE: must be BEFORE the element added to the document - if (!IE) { - object.data = "about:blank"; - } + const picker = DOM.create(""); - picker.set("tabindex", -1); + picker.on("load", {capture: true}, ["target"], this._initPicker.bind(this, picker)); picker.css("z-index", 1 + (this.css("z-index") | 0)); - this.before(picker.append(DOM.constructor(object)).hide()); - // IE: must be AFTER the element added to the document - if (IE) { - object.data = "about:blank"; - } + this.before(picker.hide()); }, _isNative() { var polyfillType = this.get("data-polyfill"), @@ -193,8 +180,8 @@ table+table[aria-hidden=true] { return TYPE_SUPPORTED; }, - _initPicker(object, picker) { - const pickerRoot = DOM.constructor(object.contentDocument); + _initPicker(picker, object) { + const pickerRoot = DOM.constructor(object.get("contentDocument")); const pickerBody = pickerRoot.find("body"); pickerBody.set(PICKER_BODY_HTML); @@ -493,4 +480,20 @@ table+table[aria-hidden=true] { picker.css("margin-top", marginTop).show(); } }); + + DOM.extend("dateinput-picker", { + constructor() { + const object = DOM.create(""); + // non-IE: must be BEFORE the element added to the document + if (!IE) { + object.set("data", "about:blank"); + } + // add object element to the document + this.append(object); + // IE: must be AFTER the element added to the document + if (IE) { + object.set("data", "about:blank"); + } + } + }); }(window.DOM, 32, 9, 13, 27, 8, 46, 17));