CN109669870A - Detecting multiple CSS files, there may be the detection methods of conflict - Google Patents

Detecting multiple CSS files, there may be the detection methods of conflict Download PDF

Info

Publication number
CN109669870A
CN109669870A CN201811555106.2A CN201811555106A CN109669870A CN 109669870 A CN109669870 A CN 109669870A CN 201811555106 A CN201811555106 A CN 201811555106A CN 109669870 A CN109669870 A CN 109669870A
Authority
CN
China
Prior art keywords
css
selectors
selector
conflict
rule
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811555106.2A
Other languages
Chinese (zh)
Inventor
张天虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Microcloud Technology Inc
Original Assignee
Guangdong Microcloud Technology Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Microcloud Technology Inc filed Critical Guangdong Microcloud Technology Inc
Priority to CN201811555106.2A priority Critical patent/CN109669870A/en
Publication of CN109669870A publication Critical patent/CN109669870A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

It detects multiple CSS files the invention discloses a kind of there may be the detection methods of conflict, the selector that parsing obtains each CSS file is carried out to each CSS file, rule, file name and it is stored in database, any one selector is successively compared to remaining selector in the affiliated CSS file of the selector in sequence, later, the selector is successively compared to the selector in residue CSS file in sequence again, if two selectors of comparison are identical, and the rule states attribute of two selectors is identical and assignment difference determines that the CSS rule of two selectors has conflict, conflict mark is carried out to the CSS rule of two selectors and saves database.The present invention can just detect conflict that may be present before quoting multiple CSS style files, research staff can know and solve in advance, while can detecte repeat pattern and optimizing CSS file, reduce CSS file size, improve loading velocity.

Description

Detecting multiple CSS files, there may be the detection methods of conflict
Technical field
The invention belongs to technical field of software development, and in particular to a kind of to detect multiple CSS files there may be conflicts Detection method.
Background technique
CSS full name is " cascading style sheets (Cascading Style Sheets) ", it is mainly used for defining in HTML Hold the pattern shown in browser, such as text, color, visual static effects, layout etc..CSS is designed in Web and is led Domain is a breakthrough, and one small pattern of modification may be implemented using it and update associated all page elements.
In general, can quote multiple CSS files in a WEB engineering, these CSS files are that developer is customized a bit , also some are that reference plugin library may result in pattern when these CSS files are loaded into a WEB page simultaneously Conflict, causes style sheet entanglement etc., needs manually to check code at this moment to find and causes the CSS rule of conflict to eliminate CSS conflict, it is time-consuming and laborious.
Meanwhile when developing a WEB engineering, CSS style file is to write maintenance by multiple research and development engineers, with Projects constantly improve, and CSS rule also can be more and more, can inevitably introduce the CSS rule of redundancy in this way, increase CSS File size causes network load slow.
Summary of the invention
In view of this, detecting multiple CSS files the main purpose of the present invention is to provide a kind of there may be the inspections of conflict Survey method.
In order to achieve the above objectives, the technical scheme of the present invention is realized as follows:
The embodiment of the present invention, which provides, a kind of to be detected multiple CSS files there may be the detection method of conflict, this method are as follows: right Each CSS file carries out parsing the selector for obtaining each CSS file, rule, file name and is stored in database, will appoint Selector of anticipating successively compares in the affiliated CSS file of the selector remaining selector in sequence, and then by the selector The selector in residue CSS file is successively compared in sequence, if two selectors of comparison are identical, and two selectors Rule states attribute is identical and assignment difference determines that the CSS rule of two selectors has conflict, to the CSS of two selectors Rule carries out conflict mark and saves database.
In above scheme, if this method further include comparison two selectors it is not identical, and rules properties and tax It is worth identical, mark is optimized to the CSS rule of two selectors and saves database.
In above scheme, the CSS rule to two selectors carries out conflict mark and saves database or right After the CSS rule of two selectors optimizes mark and saves database, this method further include: determine conflict mark or Two selectors that person optimizes mark belong to the same CSS file or belong to different CSS files.
In above scheme, if it is determined that two selectors of conflict mark are identical to belong to the same CSS file, selects two The CSS rule for selecting device carries out deleting processing.
In above scheme, if it is determined that two selectors for optimizing mark are not identical and belong to the same CSS file, right The CSS rule of two selectors is grouped selector merging treatment.
In above scheme, if it is determined that two selectors of conflict mark are identical and are not belonging to the same CSS file, mention Show whether user carries out deleting processing to the CSS rule of two selectors.
In above scheme, if it is determined that two selectors for optimizing mark are not identical and be not belonging to the same CSS, to two The CSS rule of a selector is grouped selector optimization mark.
In above scheme, the CSS rule to two selectors carries out deleting processing, specifically: in described two choosings When selecting device and belonging to the same CSS file, the CSS rule coverage for the selector being located behind is located at the CSS rule of the selector in front Then;When described two selectors are not belonging to the same CSS file, any one selector is deleted according to the user's choice CSS rule.
In above scheme, the CSS rule to two selectors is grouped selector merging treatment, specifically: it will Two selectors, which merge, becomes a grouping selector.
It is described that selector, rule, the file that parsing obtains each CSS file are carried out to each CSS file in above scheme Title and it is stored in database, specifically: if the CSS file includes grouping selector, partition generation is carried out to it Single selector, rule and file name.
Compared with prior art, the present invention can just detect conflict that may be present before quoting multiple CSS style files, Research staff can know and solve in advance, while can detecte repeat pattern and optimizing CSS file, reduces CSS file size, Improve loading velocity.
Detailed description of the invention
Fig. 1 is provided for the embodiment of the present invention and a kind of detected multiple CSS files there may be the processes of the detection method of conflict Figure;
Fig. 2 is provided for the embodiment of the present invention and a kind of detected multiple CSS files there may be carry out in the detection method of conflict Optimize the flow chart of mark.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.
The embodiment of the present invention provide it is a kind of detect multiple CSS files there may be the detection method of conflict, as shown in Figure 1, This method is realized by following steps:
Step 101: each CSS file being carried out to parse the selector for obtaining each CSS file, rule, file name simultaneously And it is stored in database;
Specifically, if the CSS file includes grouping selector, partition is carried out to it and generates single selector, rule Then and file name.
For example, just like giving a definition in test.css file, p { color:blue;text-align:center;Can be Selector p, rule { color:blue;text-align:center;, filename test.css records (such as a data Shown in table 1) it is stored in database.
Table 1
Such as it is grouped selector h1, h2, p { color:green;}
It is split as following 3:
h1{color:green;}
h2{color:green;}
p{color:green;}
Data-base recording is as shown in table 2:
Table 2
Step 102: any one selector is successively compared to remaining selection in the affiliated CSS file of the selector in sequence Device;
Step 103: the selector is successively compared to the selector in residue CSS file in sequence again;
Step 104: judging the CSS rule of two selectors of comparison with the presence or absence of conflict.
Specifically, if two selectors of comparison are identical, and the rule states attribute of two selectors is identical and assign There is conflict in the CSS rule for being worth two selectors of different determinations, carry out conflict mark to the CSS rule of two selectors and protect Deposit data library.
If two selectors of comparison are not identical, and rules properties and assignment are identical, to the CSS of two selectors Rule optimizes mark and saves database.
As shown in Fig. 2, if two selectors are identical, and the rule states attribute in two selectors it is not identical or When rule states attribute and assignment all the same, described two selectors are optimized into mark;Conversely, then continuing to compare next Selector.
If two selectors are not identical, and when rule states attribute and assignment all the same in two selectors, will Described two selectors optimize mark;Conversely, then continuing to compare next selector.
After the step 104, determine that conflict mark or two selectors of optimization mark belong to the same CSS file Or belong to different CSS files.
Specifically, if it is determined that two selectors of conflict mark are identical to belong to the same CSS file, to two selectors CSS rule carry out deleting processing.
If it is determined that two selectors of optimization mark are not identical and belong to the same CSS file, to two selectors CSS rule be grouped selector merging treatment.
If it is determined that two selectors of conflict mark are identical and are not belonging to the same CSS file, prompt the user whether The CSS rule of two selectors is carried out deleting processing.
If it is determined that two selectors of optimization mark are not identical and be not belonging to the same CSS, to two selectors CSS rule is grouped selector optimization mark.
The CSS rule to two selectors carries out deleting processing, specifically: belong in described two selectors same When a CSS file, the CSS rule coverage for the selector being located behind is located at the CSS rule of the selector in front;Described two When selector is not belonging to the same CSS file, the CSS rule of any one selector is deleted according to the user's choice.
The CSS rule to two selectors is grouped selector merging treatment, specifically: two selectors are closed And become a grouping selector.
For example, selector .mydiv1 { clore:red } and selector .mydiv2 { clore:red }, can optimize, be exactly It can suggest being write as .mydiv, mydiv2 { clore:red }, which merges, becomes a grouping selector.
Further, this method further includes that the conflict and optimization list of all CSS files are exported from database, each CSS file accounts for a tab page.
The foregoing is only a preferred embodiment of the present invention, is not intended to limit the scope of the present invention.

Claims (10)

  1. It detects multiple CSS files 1. a kind of there may be the detection methods of conflict, which is characterized in that this method are as follows: to each CSS File carries out parsing the selector for obtaining each CSS file, rule, file name and is stored in database, by any one Selector successively compares remaining selector in the affiliated CSS file of the selector in sequence, and then by the selector according to suitable Sequence successively compares the selector in residue CSS file, if two selectors of comparison are identical, and the rule of two selectors Statement attribute is identical and assignment difference determines that the CSS rule of two selectors has conflict, to the CSS rules of two selectors into Row conflict mark and save database.
  2. 2. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 1, which is characterized in that should If method further include comparison two selectors it is not identical, and rules properties and assignment are identical, to two selectors CSS rule optimizes mark and saves database.
  3. 3. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 1 or 2, which is characterized in that The CSS rule to two selectors carries out conflict mark and saves database, or to the CSS rule of two selectors After optimizing mark and saving database, this method further include: determine two choosings of conflict mark or optimization mark Device is selected to belong to the same CSS file or belong to different CSS files.
  4. 4. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 3, which is characterized in that such as Fruit determines that two selectors of conflict mark are identical and belongs to the same CSS file, deletes the CSS rule of two selectors Processing.
  5. 5. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 4, which is characterized in that such as Fruit determines that two selectors of optimization mark are not identical and belong to the same CSS file, to the CSS rules of two selectors into Row grouping selector merging treatment.
  6. 6. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 5, which is characterized in that such as Fruit determines that two selectors of conflict mark are identical and are not belonging to the same CSS file, prompts the user whether to select two The CSS rule of device carries out deleting processing.
  7. 7. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 6, which is characterized in that such as Fruit determines that two selectors of optimization mark are not identical and are not belonging to the same CSS, carries out to the CSS rule of two selectors It is grouped selector optimization mark.
  8. 8. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 7, which is characterized in that institute It states and the CSS rule of two selectors is carried out deleting processing, specifically: belong to the same CSS file in described two selectors When, the CSS rule coverage for the selector being located behind is located at the CSS rule of the selector in front;Described two selectors not When belonging to the same CSS file, the CSS rule of any one selector is deleted according to the user's choice.
  9. 9. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 8, which is characterized in that institute It states and selector merging treatment is grouped to the CSS rule of two selectors, specifically: merging two selectors becomes one It is grouped selector.
  10. 10. there may be the detection methods of conflict for the multiple CSS files of detection according to claim 9, which is characterized in that institute It states and each CSS file is carried out parsing the selector for obtaining each CSS file, rule, file name and is stored in database, Specifically: if the CSS file includes grouping selector, partition is carried out to it and generates single selector, rule and file Title.
CN201811555106.2A 2018-12-19 2018-12-19 Detecting multiple CSS files, there may be the detection methods of conflict Pending CN109669870A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811555106.2A CN109669870A (en) 2018-12-19 2018-12-19 Detecting multiple CSS files, there may be the detection methods of conflict

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811555106.2A CN109669870A (en) 2018-12-19 2018-12-19 Detecting multiple CSS files, there may be the detection methods of conflict

Publications (1)

Publication Number Publication Date
CN109669870A true CN109669870A (en) 2019-04-23

Family

ID=66144979

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811555106.2A Pending CN109669870A (en) 2018-12-19 2018-12-19 Detecting multiple CSS files, there may be the detection methods of conflict

Country Status (1)

Country Link
CN (1) CN109669870A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114385167A (en) * 2022-01-12 2022-04-22 平安普惠企业管理有限公司 Front-end page generation method, device, equipment and medium
US11868766B2 (en) 2022-03-15 2024-01-09 HCL America Inc. Method and system for identifying duplicate cascading style sheets (CSS) selector declarations

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7447706B2 (en) * 2005-04-01 2008-11-04 Microsoft Corporation Method and system for generating an auto-completion list for a cascading style sheet selector
CN103500118A (en) * 2013-10-24 2014-01-08 北京奇虎科技有限公司 Method and device for optimizing cascading style sheet
CN104252412A (en) * 2013-06-28 2014-12-31 国际商业机器公司 Method and system used for automatic detection of CSS (Cascading Style Sheet) conflict

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7447706B2 (en) * 2005-04-01 2008-11-04 Microsoft Corporation Method and system for generating an auto-completion list for a cascading style sheet selector
CN104252412A (en) * 2013-06-28 2014-12-31 国际商业机器公司 Method and system used for automatic detection of CSS (Cascading Style Sheet) conflict
CN103500118A (en) * 2013-10-24 2014-01-08 北京奇虎科技有限公司 Method and device for optimizing cascading style sheet

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
WEIXIN_34218579: "如何处理有冲突的CSS规则", 《CSDN,HTTPS://BLOG.CSDN.NET/WEIXIN_34218579/ARTICLE/DETAILS/85544119》 *
张一驰: "样式冲突:CSS选择器的战争", 《华章》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114385167A (en) * 2022-01-12 2022-04-22 平安普惠企业管理有限公司 Front-end page generation method, device, equipment and medium
US11868766B2 (en) 2022-03-15 2024-01-09 HCL America Inc. Method and system for identifying duplicate cascading style sheets (CSS) selector declarations

Similar Documents

Publication Publication Date Title
US8516406B1 (en) Methods, systems, and articles of manufacture for smart pattern capturing and layout fixing
CN106662986B (en) The browser render process of optimization
US7844422B2 (en) Method and system for changing a description for a state transition function of a state machine engine
US9251299B1 (en) Methods, systems, and articles of manufacture for associating track patterns with rules for electronic designs
Darav et al. Eh? Placer: A high-performance modern technology-driven placer
CN116209997A (en) System and method for classifying software vulnerabilities
CN106773541A (en) Photoetching solution prediction method based on layout geometric feature matching
CN109669870A (en) Detecting multiple CSS files, there may be the detection methods of conflict
CN107797820A (en) Method and apparatus for generating patch
CN104750496A (en) Automatic checking method for change influence degree of model
US8645902B1 (en) Methods, systems, and computer program products for implementing interactive coloring of physical design components in a physical electronic design with multiple-patterning techniques awareness
CN108664471A (en) Text region error correction method, device, equipment and computer readable storage medium
CN106843996A (en) Conditional compilation preprocess method and device
CN111368241A (en) Webpage element identification method based on XPath
US8688612B2 (en) Method and device for saving triple for verifying reason and incremental reasoning, and method and device for reason-dependent indexing appropriate for same
CN104252412B (en) Method and system for the automatic detection of CSS conflicts
CN111597769A (en) Method, apparatus and storage medium for generating circuit layout pattern
CN114143109B (en) Visual processing method, interaction method and device for attack data
US20050050500A1 (en) The use of a layout-optimization tool to increase the yield and reliability of vlsi designs
CN108595460A (en) Multichannel evaluating method and system, the computer program of keyword Automatic
KR20210053831A (en) A server and a computer program building a join tree
US9489451B2 (en) Visual data definition for identifying data items in loosely-structured data
KR102254951B1 (en) A server and a computer program building a join tree
CN106776348A (en) Testing case management and device
RU2433467C1 (en) Method of forming aggregated data structure and method of searching for data through aggregated data structure in data base management system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20190423

RJ01 Rejection of invention patent application after publication